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

2020-07-28 Thread Noam Yorav-Raphael
Thanks! I opened a new thread in python-ideas, here: https://mail.python.org/archives/list/python-id...@python.org/thread/6OLEL4XTUWXRI7ENODKEDOYFBRVDYKI7/ The "first" thread was very long, and was focused on a different function, first(). Perhaps a new thread, focused on one simple function in it

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

2020-07-28 Thread Noam Yorav-Raphael
I'm sorry, I don't think I got that. I don't find a mailing list called itertools-ideas. Do you mean this should go to python-ideas? If so, I'm sorry for bothering python-dev, and I'll move this to python-ideas. I just read "The python-ideas list is for discussing more speculative design ideas" (h

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

2020-07-27 Thread Noam Yorav-Raphael
Thanks for the suggestion! I agree that using a list is clearer that having a trailing comma, I like it! I still think that having a one() function would be useful, since: 1. I think it spells the intention more clearly. Also the exception would be easier to understand, since errors in tuple unpac

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

2020-07-27 Thread Noam Yorav-Raphael
Hi, There's a simple function that I use many times, and I think may be a good fit to be added to itertools. A function that gets an iterator, and if it has exactly one element returns it, and otherwise raises an exception. This is very useful for cases where I do some sort of query that I expect