On 05/22/2020 05:11 PM, David Mertz wrote:
On 05/22/2020 04:43 AM, Steven D'Aprano wrote:
i = somelist.index(needle, pred=comparison)
Why not just this (by object, not by its index, but that seems simpler): >>> do_something(next(filter(pred, somelist))) Something about 55 >>> somelist [3, 4, 29, 23, 46, 55, 90, 81] >>> pred <function div5 at 0x7fd10794ee50>
Steven, using David's example list, what would `needle` and `comparison` be in your proposal? -- ~Ethan~ _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/S2BQMHS3AMCLTCL5XEXXG3NUDD3WROJH/ Code of Conduct: http://python.org/psf/codeofconduct/