Controlling assignation

Xavier Décoret Xavier.Decoret at imag.fr
Mon Jun 13 15:52:14 CEST 2005


I would like to know if there is for python's classes an equivalent of 
the operator= that can be overidden.

Let's say I have
 >>> a=A()
and I want to write
 >>> a=5
and I want this to change some internal value of a instead of making a 
point to a new object (an int 5)

In other word, I would like to be able to use a=5 instead of a.set(5)

Is that possible?



More information about the Python-list mailing list