Finding a python object in c++
jepler at unpythonic.net
jepler at unpythonic.net
Thu Sep 16 20:49:50 EDT 2004
Access the 'im_self' attribute of the bound function object. In C,
I suppose this is something like
PyObject_GetAttrString(bound_m, 'im_self')
>>> class F:
... def m(self): pass
...
>>> f = F()
>>> bound_m = f.m
>>> dir(bound_m)
['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__get__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__repr__', '__setattr__', '__str__', 'im_class', 'im_func', 'im_self']
>>> bound_m.im_self is f
1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20040916/788caf60/attachment.sig>
More information about the Python-list
mailing list