What is not objects in Python?

George Sakkis george.sakkis at gmail.com
Mon Sep 29 17:54:58 CEST 2008


On Sep 29, 11:37 am, bearophileH... at lycos.com wrote:
> George Sakkis:
>
> > No difference in principle, just len() happens to be implemented more
> > often than upper().
>
> That's an important point. In a language that tries to be both
> practical, readable, and elegant, the things that are done more may
> deserve some sugar, to avoid code like this in many cases:
>
> sorted(seq, key=lambda x:x.__len__())

If this was the most compelling use case of having len as builtin, I
would be even less convinced. How often do you sort by len? FWIW, the
most common sorting keys I see in real world are attrgetter(some_attr)
or itemgetter(some_index)  and both are imported functions, not
builtins.

George



More information about the Python-list mailing list