Message242222
If there is nothing to sort (i.e. one item), why call key function at all?
In my practical situation, simplest key() function will lead to recursion in case of such trivial lists. I can make similar cmp-type function (i.e. mycmp=lambda a, b: cmp(key(a), key(b))) and then wrap this with cmp_to_key. But that looks silly.
Simple test case:
$ cat a.py
a = [1]
def spam(x):
raise Exception
a.sort(key=spam)
print(a)
$ python a.py
Traceback (most recent call last):
File "a.py", line 6, in <module>
a.sort(key=spam)
File "a.py", line 4, in spam
raise Exception
Exception |
|
Date |
User |
Action |
Args |
2015-04-29 13:30:43 | Sergey.Kirpichev | set | recipients:
+ Sergey.Kirpichev |
2015-04-29 13:30:43 | Sergey.Kirpichev | set | messageid: <1430314243.47.0.686981874079.issue24075@psf.upfronthosting.co.za> |
2015-04-29 13:30:43 | Sergey.Kirpichev | link | issue24075 messages |
2015-04-29 13:30:43 | Sergey.Kirpichev | create | |
|