Using equals operator without changing reference pointer

Erik Max Francis max at alcyone.com
Thu Jan 29 22:04:49 EST 2009


mark.seagoe at gmail.com wrote:

> Is there a way to lock down myInst so that it still refers to the
> original object, and is there some special member that will allow me
> to override the equals operator in this case?  Or is that simply
> blasphemous against everything Python holds sacred?  Certainly there
> is some keyword that I don't know about.

No.  The assignment operator with a bare name on the left hand side is 
not overridable.

You can override attribute access, however, with 
.__getattr__/.__getattribute__.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   The perfection of innocence, indeed, is madness.
    -- Arthur Miller



More information about the Python-list mailing list