list.reverse()
Erik Max Francis
max at alcyone.com
Fri Nov 15 21:38:36 EST 2002
Mike Dean wrote:
> I think I recall seeing a reasonable explanation for this earlier
> (probably referring actually to list.sort()), but I'm wondering - what
> was the rationale for making list.reverse() reverse a list in-place
> rather than return a new, reversed list? I'm sure there's a good
> reason, but what might that be?
Optimization. If you want a copy of a reversed list, make a copy of
your list and then reverse that:
l2 = l[:]
l2.reverse()
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ Give me chastity, but not yet.
\__/ St. Augustine
WebVal / http://www.alcyone.com/pyos/webval/
URL scanner, maintainer, and validator in Python.
More information about the Python-list
mailing list