Newbie Questions: Swithing from Perl to Python

Aahz aahz at pythoncraft.com
Sun Oct 26 01:40:15 EDT 2003


In article <roy-D86C06.22163525102003 at reader1.panix.com>,
Roy Smith  <roy at panix.com> wrote:
>
>My personal opinion is that you should be able to do the simplier:
>
>for key in myDict.keys().sort()
>   print key
>
>but unfortunately, sort doesn't work like that.  It sorts the list 
>in-place and does NOT return the sorted list.

Yup.  Guido doesn't want you copying the list each time you sort; it's
easy enough to make your own copy function.  Nevertheless, it appears
likely that 2.4 will grow list.sorted() (yes, a static method on the
list type).
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan




More information about the Python-list mailing list