Using eval, or something like it...

Scott David Daniels Scott.Daniels at Acm.Org
Thu Nov 20 13:42:17 EST 2008


r0g wrote:
> John Machin wrote:
>> .... You mention "variables of a class" but you then proceed to poke
>> at an instance of the class....
>> Check out setattr (and getattr) in the docs.
> The former i.e. the variables of an instance of a class. Thanks :-)

Careful here.  Your wording seems to indicate you misunderstand the
Python model.  The instance doesn't have variables (and your class built
nothing that could be called an instance variable).  Think of the
attributes of an instance (or a class) as "values attached to (or
associated with) the instance."  If you don't you are setting yourself
up to discover a pile of bugs that you don't understand.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list