Michael Hoffman wrote:

>> def list_members(obj)
>>l = dir(obj)
>>return map(lambda x : eval('obj.'+x), l)
> 
> That works fine for me with Python 2.4.

Python 2.4 (#6, Jan 30 2005, 11:14:08)
[GCC 3.3.3 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def lm(obj):
...     l = dir(obj)
...     return map(lambda x: eval("obj." + x), l)
...
>>> class X:
...     pass
...
>>> x = X()
>>> x.question = "Are you sure?"
>>> lm(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 3, in lm
  File "<stdin>", line 3, in <lambda>
  File "<string>", line 0, in ?
NameError: name 'obj' is not defined
>>>

Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to