using getattr/setattr for local variables in a member function
davea at davea.name
Fri Nov 22 03:02:06 CET 2013
On Fri, 22 Nov 2013 00:52:21 +0000, MRAB <python at mrabarnett.plus.com>
> > If I have a class that has some member functions, and all the
> > define a local variable of the same name (but different type), is
> > some way to use getattr/setattr to access the local variables
> > to a given function?
If you mean to access them from within the same method, someone else
has already shown it using locals(). But you cannot access locals
from a method that's already terminated. They no longer exist.
More information about the Python-list