Message30663
Quote:
Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e < x, and all e in a[i:] have e >= x. So if x already appears in the list, i points just before the leftmost x already there.
The last sentence is incorrect, and it contradicts what comes earlier. Not knowing which is correct, I had to test it in the shell.
>>> from bisect import *
>>> l = [1,2,3,3,3,4,5]
>>> bisect_left(l,3)
2
>>> l[2:]
[3, 3, 3, 4, 5]
It should be changed to read "i points at the leftmost x already there"
-Dan |
|
Date |
User |
Action |
Args |
2007-08-23 14:50:15 | admin | link | issue1602378 messages |
2007-08-23 14:50:15 | admin | create | |
|