Python doesn't know class of function ? : class C:def f():pass; l=[f]; print C.l[0].im_class

Robert k.robert at
Fri Mar 19 11:26:57 CET 2004

Python doesn't know the class of a method when container not direct
class attribute:

>>> class X:
... 	def f():pass
... 	g=f
... 	l=[f]
>>> X.g
<unbound method X.f>
>>> X.l[0]
<function f at 0x01A9E1F0>
>>> X.l[0].im_class
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
AttributeError: 'function' object has no attribute 'im_class'

why is l[0] a <function>. Any possibility to find the class of this
beast dynamically?


More information about the Python-list mailing list