Re: Adding attribute to objetcs

2006-06-05 Thread Bruno Desthuilliers
faulkner a écrit : (please, don't top-post - corrected) > > Miguel Galves wrote: > >>Hello, >> >>I`m starting to learn python, and I hava a very good background in Java >>and C/C++ programming. I was reading Dive into python chapter about >>OO and I saw that in python we can do the following: >>

Re: Adding attribute to objetcs

2006-06-05 Thread faulkner
when you set an attribute of an object, python secretly calls that objects __setattr__ method. class test: def __setattr__(self, attr_name, attr_value): print self, attr_name, attr_value self.__dict__[attr_name] = attr_value# do what the original __setattr__ method does. tes