can this b done
JyotiC
jyoti.chhabra at gmail.com
Thu Aug 3 03:56:53 EDT 2006
thanx for the help
Gary Herron wrote:
> JyotiC wrote:
> > hi,
> >
> > i hv a var of type IntVar, ca i get the name of this variable
> >
> > eg:-
> > class someclass:
> > def somefun(...):
> > self.var=IntVar()
> > ....
> >
> > def someotherfun(...):
> > in this fun can i get the name of var.
> > as in, can i get name var as a string 'var'
> >
> > Thanx
> >
> >
> Perhaps this will do what you want:
>
> An instance of a class maintains a dictionary of all it's local
> variables. One of those will be self.var, but any other local variables
> will also be in the dictionary -- I have no idea how you plan to specify
> *which* local variable you want the name of.
>
> Anyway, the dictionary is:
> self.__dict__
> and the list of variable names is the dictionary's keys:
> self.__dict__.keys()
> and one of the elements in that list will be the string:
> 'var'
>
> Hope that helps:
>
> Gary Herron
More information about the Python-list
mailing list