[Python-ideas] Re: Function suggestion: itertools.one()

2020-08-08 Thread Stefano Borini
+1 very useful also for me. Once in a while I have this exact scenario. Not often enough to get annoyed, but often enough that it would be nice to have. On Tue, 28 Jul 2020 at 20:27, Noam Yorav-Raphael wrote: > > Hello, > > There's a simple function that I use many times, and I think may be a goo

[Python-ideas] Re: Function suggestion: itertools.one()

2020-07-28 Thread Sebastian Kreft
Check the thread https://mail.python.org/archives/list/python-ideas@python.org/thread/REYDJFCXQNQG4SAWKELQMCGM77IZG47Q/#CGMWPLJME4ZZNGHDY4DGCSF347VBMAKZ There are comments in favor of both first and one. On Tue, Jul 28, 2020 at 3:59 PM Noam Yorav-Raphael wrote: > Thanks! It's good to hear that

[Python-ideas] Re: Function suggestion: itertools.one()

2020-07-28 Thread Noam Yorav-Raphael
Thanks! It's good to hear that you too find it useful. Since adding methods to built-in types is much heavier than adding one function to a module, l suggest keeping this discussion focused on adding just the one() function to itertools, and see if there is enough support for this. Cheers, Noam

[Python-ideas] Re: Function suggestion: itertools.one()

2020-07-28 Thread Alex Hall
In my personal toolbox of utility functions, this is by far the function I use most often, although it's implemented slightly differently and I call it `only`. I think it's very useful and it would be great to have in the standard library to encourage people to write safer code. Often this is part