homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author remi.lapeyre
Recipients Dima.Tisnek, NeilGirdhar, alex, bls, dmtr, ericreynolds, flyingosprey, gregory.p.smith, jafo, josh.r, mark.dickinson, martin.panter, milko.krachounov, remi.lapeyre, rhettinger, tebeka, terry.reedy, wumpus, yselivanov
Date 2019年05月26日.14:25:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558880752.33.0.822360328328.issue4356@roundup.psfhosted.org>
In-reply-to
Content
Can you not use functools.cmp_to_key() for this?
Here's an example:
>>> import bisect, functools
>>> l = [('f', 5), ('d', 3), ('c', 2), ('b', 1), ('a', 0)]
>>> def cmp(a, b):
... if a > b: return -1
... if a < b: return 1
... return 0
... 
>>> bisect.bisect(l, ('e', 4), key=functools.cmp_to_key(cmp))
1
>>> l
[('f', 5), ('d', 3), ('c', 2), ('b', 1), ('a', 0)]
>>> bisect.insort(l, ('e', 4), key=functools.cmp_to_key(cmp))
>>> l
[('f', 5), ('e', 4), ('d', 3), ('c', 2), ('b', 1), ('a', 0)]
History
Date User Action Args
2019年05月26日 14:25:52remi.lapeyresetrecipients: + remi.lapeyre, rhettinger, terry.reedy, gregory.p.smith, jafo, tebeka, mark.dickinson, alex, milko.krachounov, dmtr, bls, martin.panter, Dima.Tisnek, yselivanov, NeilGirdhar, josh.r, ericreynolds, wumpus, flyingosprey
2019年05月26日 14:25:52remi.lapeyresetmessageid: <1558880752.33.0.822360328328.issue4356@roundup.psfhosted.org>
2019年05月26日 14:25:52remi.lapeyrelinkissue4356 messages
2019年05月26日 14:25:52remi.lapeyrecreate

AltStyle によって変換されたページ (->オリジナル) /