-1
data.name='Some Name'
col1='name'

data.col1  ???

how to access data using only var col1,
like data.col1 or some thing
Simple the variable name is stored in another variable, actually from a django request.

limovala
  • 459
  • 1
  • 5
  • 16
  • Is [this](http://stackoverflow.com/a/9437799/645270) what you want? They mention `eval` as well. You could also rewrite the response so that it returns some status code instead. – keyser Jun 09 '13 at 08:49
  • @MartijnPieters how the ,will you reach on that possible duplicate by searching with 'variable inside another variable for python'. you have to know that thing after . is an attribute to search like that. moderators. – limovala Jun 09 '13 at 14:36
  • That is what duplicates are for; if you search *next* time, you will find this one, which automatically redirects you to the other one. Don't worry about it. – Martijn Pieters Jun 09 '13 at 14:40

1 Answers1

2

Use getattr:

getattr(data,col1)
korylprince
  • 2,969
  • 1
  • 18
  • 27