Overloadable Assignment PEP
Drew Moore
drew at astro.pas.rochester.edu
Fri Apr 4 14:56:03 EST 2003
Michael Hudson <mwh at python.net> wrote in message news:<7h3d6k2jtoi.fsf at pc150.maths.bris.ac.uk>...
> drew at astro.pas.rochester.edu (Drew Moore) writes:
>
> > I'd like this PEP to go one of two ways..
> > either implementation,
> > or a good solid technical reason why its a bad idea.
>
> How about: it involves changing the language into something it's not.
>
> For a more technical sounding reason, how do you cope with the fact
> that `=' can both establish and change a binding?
>
> Cheers,
> M.
I think I came up with a reason.
when the overloading object is always on the left side of the assign,
I think things stay pretty benign.
When they appear on the right side, however, you get trouble..
The overloading is sticky.. contagious.. eek!
for s in L : # loop thru list of things..
p = s # hey, what if an item in the list overloads assignment?
# it overloads it for the remainder of the loop!
Sounds like an easy way to shoot yourself in the foot.
I can't think of a sensible way around this.
Drew
More information about the Python-list
mailing list