Modifying the {} and [] tokens

Just just at
Sun Aug 24 09:57:07 CEST 2003

In article <Zi6dnd57h5jI-tWiXTWJkA at>,
 "Terry Reedy" <tjreedy at> wrote:

> "> 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().
> One point someone made is summarized by the following contrast:
> collections = (atuple, alist, adict, someothercollection)
> flengths = map(len, collections) #actual
> mlengths = map(lambda obj: gettattr(obj, 'len')(), collections)
> #hypothetical

  mlengths = map(lambda obj: obj.len(), collections)

> # or listcomp equivalents

That would be much better than the lambda version:
  mlengths = [x.len() for x in collections]


More information about the Python-list mailing list