using getattr/setattr for local variables in a member function

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Nov 21 23:07:49 EST 2013


Catherine M Moroney wrote:
> is there
> some way to use getattr/setattr to access the local variables specific 
> to a given function?

No, because those variables don't even exist when there
isn't a call to the function in progress.

Your example suggests that, instead of local variables,
you really want them to be attributes of your object
somehow. The best way to go about that will depend on
how you want to use them.

If you explain more about the problem you're trying
to solve, we may be able to suggest a solution.

-- 
Greg



More information about the Python-list mailing list