nperkins7 at home.com
Sun Jun 17 15:22:31 EDT 2001
"Rikard Bosnjakovic" <bos at hack.org> wrote in message
> >>> l = l
I am pretty sure that
l = l
will never have any effect, whatsoever.
Assignment never creates a copy of the data, it just 'points' to the same
( or "refers to the same object" )
This just makes l point to whatever it already points to. No effect.
I do find it a bit strange that list.sort() returns None, but I am sure
there is a good reason for that.
It is also strange that you can legally do:
..but you can not recover the sorted list.
a = [3,2,5].sort()
assert a == None
I presume that the list actually gets sorted, but since no referece is
maintained to the list, it immediately becomes 'garbage', and is lost
..the same goes for list.reverse()...
If they both returned references to themselves, you could do:
a = [3,2,5].sort().reverse()
assert a == [5,3,2]
More information about the Python-list