ok, so how do I return a sorted list without doing it in place

Kalle Svensson kalle at gnupung.net
Fri Feb 16 20:01:22 EST 2001


Sez Phlip:
> Proclaimed Sean 'Shaleh' Perry from the mountaintops:
[list.sort() returns None]
> 
> I don't know why a more useful return value couldn't have been supplied, 

See http://www.python.org/doc/current/lib/typesseq-mutable.html, footnote 5,
for the reasoning of the designers:

"""
The sort() and reverse() methods modify the list in place for economy of
space when sorting or reversing a large list. They don't return the sorted
or reversed list to remind you of this side effect.
"""

Peace,
  Kalle
-- 
Email: kalle at gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20010217/1c4b69c0/attachment.sig>


More information about the Python-list mailing list