operator overloading + - / * = etc...
steve at holdenweb.com
Sun Oct 8 12:44:18 CEST 2006
Tim Chase wrote:
>>>Can these operators be overloaded?
> 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. There might be some oddball way
> to do it via property() but AFAIK, this only applies to
> properties of objects, not top-level names/variables. I'd love
> to know if there's some workaround for this though...
That's because assignment isn't an operator - that's why (for example)
print x = 33
would be a syntax error. This is a deliberate design decision about
which, history shows, there is little use complaining.
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list