odd behavior

Greg gstgeorge at gmail.com
Fri Nov 11 14:34:47 EST 2005


Forgive me, and be kind, as I am just a newby learning this language
out of M.L. Hetland's book.  The following behavior of 2.4.1 seems very
strange
>>> x = ['aardvark', 'abalone', 'acme', 'add',
     'aerate']
>>> x.sort(key=len)
>>> x
['add', 'acme', 'aerate', 'abalone', 'aardvark']
>>> x.sort(reverse=True)
>>> x
['aerate', 'add', 'acme', 'abalone', 'aardvark']
The function called on line 4, at least to me, should work on x as it
was on line 3, not the previously existing x on line 1.  What gives?
By the way these functions do not exist in 2.3.5 so they must be newly
implemented.




More information about the Python-list mailing list