Why not an __assign__ method?
Grant Edwards
grante at visi.com
Fri Mar 30 13:59:33 EST 2001
In article <EF3x6.114663$Ch.15367147 at typhoon.we.rr.com>, Pete Shinners wrote:
>> The question is: Why not have a __assign__ method, that gets called on
>> assignment? It should be called on the *right side* of the expression (at
>> the left side it does not make sense - I leave the proof as an exercise for
>> the reader <wink>). The return value would be then assigned to the left
>> side of the expression. This is the default behavior:
>
>i'm not quite sure how this would work. assigning variables
>have nothing to do with the type a variable 'currently' refers to.
That's not a problem for his proposal.
>a = None
>a = huge_array1 + huge_array2
>
>the variable could point to anything before being assigned.
Exactly -- his proposal doesn't care what the left-side name
points to.
>the assignment in no way effects what the variable originally
>refers to, so it doesn't seem like whatever that was should get
>a say in what happens to the "new owner"
a = huge_array1 + huge_array2
What he wants (as I understand it) is to evaluate the RHS, call
the __assign__ method on the result of that evaluation, and
bind "a" to whatever the __assign__ method returns.
--
Grant Edwards grante Yow! Yow! I like my new
at DENTIST...
visi.com
More information about the Python-list
mailing list