You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError in bisect when called with key argument #117848
Traceback (most recent call last):
File "/path/to/bisect_test.py", line 5, in<module>
print(bisect.bisect(a, ('one', 1), key=operator.itemgetter(0)))
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'tuple' and 'str'
It seems that picking an item in a tuple has a problem.
Activity
nineteendo commentedon Apr 13, 2024
You need to apply
key()to the element:nineteendo commentedon Apr 13, 2024
See #20556 (comment)
nineteendo commentedon Apr 13, 2024
@AlexWaygood, could you close this? This works as intended.Sorry for the ping.c-m-m-kobayashi commentedon Apr 13, 2024
@nineteendo Thank you for your comment.
Now I understand that giving the field to be compared is better than the entire record in bisect search.