Why list.sort() don't return the list reference instead of None?

Tim N. van der Leeuw tim.leeuwvander at nl.unisys.com
Mon May 8 10:12:16 CEST 2006


So you write:

for key in sorted(dict.iterkeys()):
   ... do it ...

dict.iterkeys() returns an iterable which doesn't even have a
sort-method; and somehow I find it unnatural to apply a 'sort' method
to an iterator whereas I find it perfectly natural to feed an iterator
to a function that does sorting for anything iterable...

Cheers,

--Tim




More information about the Python-list mailing list