PyClass_New and __getattr__

Vlado sironja at web.de
Thu Nov 22 11:32:27 CET 2001


Hi,
here a short question; I'm extending python through
some C++ classes. I have defined a new
type with PyClass_New() and added __getattr__ 
and __setattr__ to the class dictionary.
However, these two get/set methods are not being called 
if class member resolve fails. 
An explicit call succeeds though, e.g.

>>>t=Test()
>>>t.i
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: Test instance has no attribute 'i'
>>>t.__getattr__(t,'i')
ok, test_getattr called


Am i missing something?
Thank you.
Vlado

ps. using Python21 and Python22a3 on win32



More information about the Python-list mailing list