[Tutor] Getting class method variable values
gyro funch
gyromagnetic@excite.com
Fri Jun 13 16:50:01 2003
Hi,
I am trying to have the __init__ method of my class inspect each of the class methods and create a variable based on these values.
For instance,
class C(object):
def __init__(self):
from inspect import getmembers, ismethod
self.vvalues = []
for name,value in getmembers(self):
if ismethod(value):
vnames = value.im_func.func_code.co_names
for vname in vnames:
if vname.startswith('v_'):
vvalue = ? # how do I get this?
self.vvalues.extend(vvalue)
def c1(self):
v_1 = [1,2,3]
def c2(self):
v_2 = [5,6,7]
I would like the following:
>>> myC = C()
>>> myC.vvalues
[1,2,3,5,6,7]
I can get the names of the variables (v_1,v_2), but I can't figure out how to get the value bound to each variable.
Any suggestions are appreciated.
-g
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!