operator overloading + - / * = etc...

Bruno Desthuilliers onurb at xiludom.gro
Thu Oct 12 04:48:56 EDT 2006


Georg Brandl wrote:
> Bruno Desthuilliers wrote:
>> Steven D'Aprano wrote:
>>> On Sat, 07 Oct 2006 17:21:55 -0500, Tim Chase wrote:
>>>
>>>>>> With the caveat of the "=" mentioned in the subject-line (being
>>>>>> different from "==")...I haven't found any way to override
>>>>>> assignment in the general case.
>>>>> Why would you want to do that?
>>>> For the same reason one would use property() to create getter/setter
>>>> functions for a particular variable--to intercept attempts to set a
>>>> variable.
>>>
>> (snip)
>>
>>> Suppose we bind the name "x" to the object 1, and then rebind the
>>> name "x"
>>> to the object []. Which object's hypothetical __assign__ method
>>> should get
>>> called? 
>>
>> The current namespace object, of course.
> 
> Which is?

Depends on the context... Can be actually the module (global) namespace,
a function local namespace or a class namespace.


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list