Operator overloading

Diez B. Roggisch deets at nospam.web.de
Fri Jan 25 14:16:52 EST 2008


MartinRinehart at gmail.com schrieb:
> 
> Diez B. Roggisch wrote:
>> No, there is no way. You would change general interpreter behavior if
>> you could set arbitrary operators for predefined types.
>>
>> Start grumping...
> 
> Thank you, Diez.
> 
> If I ever design a language, please remind me that complete, easy,
> well-documented access to the working of the internals (and the
> ability to change same) would be very, uh, what's the right word?
> Pythonic?

As you say - it's a question of design & thus taste. Python has chosen 
to _not_ allow to change (all) inner workings of itself in favor of not 
introducing subtle bugs that arise from somebody (accidentially or not) 
altering behavior of builtins that might effect code he'd never intended 
to touch.

But you _can_ create subclasses of these builtins and adapt their 
behavior. I for once like it that way. If you don't - to bad for you. It 
won't change, so either you live with it, or start working on your 
lex/yacc skillz and create your own language. Or switch to Ruby, which 
allow for what you desire (AFAIK, not entirely sure though)

Diez



More information about the Python-list mailing list