strings and sort()

Jason caljason76 at
Thu Feb 21 15:35:25 EST 2002

Paul Rubin <phr-n2002a at> wrote in message news:<7xg03vsidi.fsf at>...

>   b = list(a)
>   b.sort()

perfect. thanks

> In Python, that's considered immoral--it puts you in danger of
> forgetting that the sort operation modifies the list that you use it
> on.  For example, if you say
>    a = b.sort()
> expecting to get a sorted copy of b without clobbering b, you'd get
> a rude surprise.

I still think that the convenience of having sort() return the list
far outweighs the cost.  People would only get bit once, maybe twice,
before they learned the behavior of sort.

I like Python, but the biggest problem I have with the language right
now is what low code density it has at times.


More information about the Python-list mailing list