Modifying the {} and [] tokens
Michael C. Neel
neel at mediapulse.com
Mon Aug 25 11:58:37 EDT 2003
> The problem here is that, when looking at d1 + d2, it is not
> obvious what is
> going on. If the same key appears in both d1 and d2, what
> will the resulting
> dict have? The value in d1? The value in d2? Or maybe an
> exception will be
> raised? Different people will have different notions here
> about what is
> "obvious" and "natural".
>
> "Pick one and make that the standard" may work in some other
> languages, but
> that is usually not how Python's design works. If there is
> not "one obvious
> way", chances are it won't make it into the language. (Of
> course, there are
> exceptions... but this seems to be a rule-of-thumb.)
>
Sadly, I think python is taking this too far, and spends more time
debating operators than advancing the language. This has kept out ?:
and += from being allowed. And in Geoff's case here, if Python
supported traditional C++ like operator overloading, then we could have
the best of both worlds - he doesn't "replace" the builting dict, but
creates a new dict class and overloads {} and +,- or whatever else he
wishes.
Coming up with a solution that everyone likes is not going to happen...
ever (re: ', '.join([]) ). but we shouldn't rule out something because
there is not a uniamous vote (if that were so, we would have no join
method).
IMHO of cource,
Mike
More information about the Python-list
mailing list