Modifying the {} and [] tokens

Dave Brueck dave at
Sat Aug 23 12:30:07 CEST 2003

On Saturday 23 August 2003 10:12 am, Geoff Howland wrote:
> On 23 Aug 2003 08:18:49 -0700, mis6 at (Michele Simionato)
> >Python tries hard not to modify its basic syntax, so you must stay
> >with the above. Pythonista would argue that this is a strenght of the
> >language: "explicit is better than implicit".
> I agree with this philosophy too.  I'm not sure where the changes I'm
> looking to fail to be explicity.
> {} + {} makes sense right?  You are adding them together.  There will
> obviously be a possibility of key clobbering, but then you could run
> something like {}.intersect() and get the keys that will be clobbered
> (if it existed).

Does {'a':4} + {'a':6} equal
(a) {'a':10}
(b) {'a':[4,6]}
(c) {'a':4}
(d) {'a':6}


I can think of reasonable & realistic use cases where each one is the 
"obvious" choice.

> len([])
> [].len()

If you can conjure up the right Google Groups query, this has been discussed 
many times in the past (and by that I mean some good points have been raised 
that you might find interesting). In particular, I remember Alex Martelli 
making a good argument for len(obj) over obj.len(). For my part, now that I'm 
used to len(obj), the form obj.len() seems too much like 
OO-just-for-the-sake-of-OO, which isn't very compelling.


More information about the Python-list mailing list