From: <dam...@eu...> - 2001-08-22 15:31:06
|
Hi all, I'm new to [p|j]ython and have a question regarding __setattr__. I have a Java class: public JClazz { public int jfield ; } I want to subclass JClass in python and use the __setattr__ special method to customize access to the jfield attribute, for, say, print a message when jfield is being changed from python: class PClazz(JClazz): def __setattr__(self,name,value): if name != 'jfield': # for python fields, use __dict__ self.__dict__[name] = value else: print "Changing jfield..." # an then ???? My question: is there any way to set the jfield without using self.jfield which would cause a fatal recursive call to __setattr__ (ie similar to accessing __dict__ directly) ? |