eval of a private attribute
Bertrand Geston
bergeston at yahoo.fr
Thu Mar 21 10:53:47 EST 2002
"Skip Montanaro" <skip at pobox.com> wrote in message
news:mailman.1016720675.17480.python-list at python.org...
>
> Cedric> I'd like to create a method which will be able to get any
> Cedric> attribute of the class.
>
> Why use eval? Why not simply
>
> p = getattr(self.__class__, var)
>
> ? The first arg restricts you to fetching class variables. You could
also
> use 'self' there I suppose.
>
> --
> Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
>
Yes, this is right with var = '_%s__%s' % (self.__class__.__name__, var)
More information about the Python-list
mailing list