Assignment not the same as defining?

Oleg Broytmann phd at phd.pp.ru
Wed Oct 3 07:48:47 EDT 2001


On Wed, Oct 03, 2001 at 12:35:58PM +0100, Dale Strickland-Clark wrote:
> A solution I thought I had to using __setattr__ doesn't seem to work.
> 
> class wibble:
> 	def __init__(self):
> 		<init code>
> 		self.__setattr__ = self.set
> 
> 	def set(self, attr, value):
> 		<assignment code>
> 
> My late bound __setattr__ is never called.
> 
> I've clearly misunderstood something fundamental here. What am I doing
> wrong?

   Python does not have assingment at all.
a = b
   is not assignment in Python - it is binding and rebinding. Reference to
b copied into a. Only reference, not an object.

Oleg.
---- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.




More information about the Python-list mailing list