> -----Original Message----- > From: Gabriel Genellina [mailto:[EMAIL PROTECTED] > Sent: Tuesday, January 23, 2007 9:24 PM > To: python-list@python.org > Subject: Re: Overloading assignment operator > > "Carroll, Barry" <[EMAIL PROTECTED]> escribió en el mensaje > news:[EMAIL PROTECTED] > > > * ... the assignment operator is used to assign an > > * object to a name in the current namespace... IOW, you cannot "overload > > * the assignment operator." > > (wesley chun) > This is the key concept, if you want to be able to "see" assignments, you > should work with a namespace (a dictionary is enough...) > > > * result = property(get_result, set_ result, doc='result of operations') > > > > I have tested this using the admittedly simple-minded code snipped > > below. <<snip>> > Notice that you can delete ALL those lines of code, leaving a bare: > > class Aclass: passs > > and you will get EXACTLY the same results. In this case -and this are not > my > words- properties are a waste of programmer time, processor time and disk > space. > Of course properties are very useful, but when you need to do something > "more" than just storing and retrieving a single value. > > -- > Gabriel Genellina Greetings:
Gabriel is right, and my definitions of get_result and set_result were deficient. Something like this would have been better: * def get_result(self): * do_stuff_before_returning(self) * return self.__result * * def set_result (self, expression): * do_stuff_before_storing(self, expression) * self.__result = expression * Achim didn't go into the details of his result class(es), so I don't know what the do_stuff_* functions would actually do. Sorry for the omission. Regards, Barry -- http://mail.python.org/mailman/listinfo/python-list