Modifying the {} and [] tokens

Mel Wilson mwilson at
Fri Sep 12 04:07:33 CEST 2003

In article <Xns93F084E3691FDduncanrcpcouk at>,
Duncan Booth <duncan at> wrote:
>mwilson at (Mel Wilson) wrote in news:oQhU/ks/KXNd089yn at the-
>>[ ... ]
>> where additive_identity is a magical value that's 0 working
>> with numbers, [] with lists, () with tuples and '' with
>> strings.  In real life I'd catch the key errors instead.
>FWIW, Your 'magical value' isn't actually terribly magical, it is easily
>defined with a few lines of Python:
>>>> class AdditiveIdentityClass:
>	def __coerce__(self, other):
>		return type(other)(), other


        Thanks.         Mel.

More information about the Python-list mailing list