defining __setattr__ in an extension
Trevor
trevorperrin at hotmail.com
Thu Nov 21 05:03:25 EST 2002
More information about the Python-list mailing list
Thu Nov 21 05:03:25 EST 2002
- Previous message (by thread): ANN: Python Programming course (Silicon Valley, CA)
- Next message (by thread): python-dev Summary, 2002-11-01 through 2002-11-15
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello Python folks, I'm trying to define a new python class in a C extension module, following this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/54352 I'm having trouble adding a __setattr__ method. Following Vladimir's advice (see note 1 on the URL) I add the __getattr__ and __setattr__ functions to the class dictionary before calling PyClass_New. When my __getattr__ function is called, the self parameter is NULL, with self as the first argument in the args tuple. But when __setattr__ is called, the self parameter is still NULL, but self *isn't* in the args tuple, which only has two args. So I have no self, which seems alarming. Then I tried adding __setattr__ after the call to PyClass_New, like any other method, and then it doesn't appear to get called at all. So what's the appropriate way to define a __setattr__ method when using the above idiom? Trevor
- Previous message (by thread): ANN: Python Programming course (Silicon Valley, CA)
- Next message (by thread): python-dev Summary, 2002-11-01 through 2002-11-15
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list