Re: [Python-ideas] Python-ideas Digest, Vol 131, Issue 106

2017-10-31 Thread Steven D'Aprano
On Tue, Oct 31, 2017 at 10:31:50AM +, אלעזר wrote: > Off topic: why can't we simply allow something like this: > > (the_bob) = (name for name in ('bob','fred') if name=='bob') Parens don't make a tuple. They are just for grouping. If you want a tuple, you need a comma: the_bob, = .

Re: [Python-ideas] Python-ideas Digest, Vol 131, Issue 106

2017-10-31 Thread אלעזר
On Tue, Oct 31, 2017 at 12:18 PM Koos Zevenhoven wrote: > On Tue, Oct 31, 2017 at 11:24 AM, Petr Viktorin wrote: > >> On 10/31/2017 09:54 AM, Koos Zevenhoven wrote: >>> >>> >>> ​I wonder if that's more easily understood if you write it along these >>> line(s): >>> >>>(the_bob,) = ​(name for

Re: [Python-ideas] Python-ideas Digest, Vol 131, Issue 106

2017-10-31 Thread Koos Zevenhoven
On Tue, Oct 31, 2017 at 11:24 AM, Petr Viktorin wrote: > On 10/31/2017 09:54 AM, Koos Zevenhoven wrote: >> >> >> ​I wonder if that's more easily understood if you write it along these >> line(s): >> >>(the_bob,) = ​(name for name in ('bob','fred') if name=='bob') >> > > There are (unfortunate

Re: [Python-ideas] Python-ideas Digest, Vol 131, Issue 106

2017-10-31 Thread Petr Viktorin
On 10/31/2017 09:54 AM, Koos Zevenhoven wrote: On Tue, Oct 31, 2017 at 10:01 AM, Chris Angelico >wrote: On Tue, Oct 31, 2017 at 6:46 PM, Steven D'Aprano mailto:st...@pearwood.info>> wrote: > On Tue, Oct 31, 2017 at 06:02:34PM +1100, Chris Angelico wrote:

Re: [Python-ideas] Python-ideas Digest, Vol 131, Issue 106

2017-10-31 Thread Koos Zevenhoven
On Tue, Oct 31, 2017 at 10:01 AM, Chris Angelico wrote: > On Tue, Oct 31, 2017 at 6:46 PM, Steven D'Aprano > wrote: > > On Tue, Oct 31, 2017 at 06:02:34PM +1100, Chris Angelico wrote: > >> One small change: If you use next(i) instead of i.next(), your code > >> should work on both Py2 and Py3. B

Re: [Python-ideas] Python-ideas Digest, Vol 131, Issue 106

2017-10-31 Thread Chris Angelico
On Tue, Oct 31, 2017 at 6:46 PM, Steven D'Aprano wrote: > On Tue, Oct 31, 2017 at 06:02:34PM +1100, Chris Angelico wrote: >> One small change: If you use next(i) instead of i.next(), your code >> should work on both Py2 and Py3. But other than that, I think it's >> exactly the same as most people

Re: [Python-ideas] Python-ideas Digest, Vol 131, Issue 106

2017-10-31 Thread Steven D'Aprano
On Tue, Oct 31, 2017 at 06:02:34PM +1100, Chris Angelico wrote: > > def single(i): > > try: > > v =i.next() > > except StopIteration: > > raise ValueError('No items') > > try: > > i.next() > > except StopIteration: > > return v > > else: > >

Re: [Python-ideas] Python-ideas Digest, Vol 131, Issue 106

2017-10-31 Thread Chris Angelico
On Tue, Oct 31, 2017 at 5:18 PM, Ivan Pozdeev via Python-ideas wrote: >> raise WhitespaceDamagedException from None > > > Thunderbird jerked on me big time. It never did anything like this before! > Switched off Digest mode, individual messages aren't so complicated. > > def single(i): > try:

Re: [Python-ideas] Python-ideas Digest, Vol 131, Issue 106

2017-10-30 Thread Ivan Pozdeev via Python-ideas
On 31.10.2017 8:37, python-ideas-requ...@python.org wrote: On Tue, Oct 31, 2017 at 3:50 PM, Ivan Pozdeev via Python-ideas wrote: On 30.10.2017 17:32, Guido van Rossum wrote: This is a key example of a case where code speaks. Can you write an implementation of how you would want single() to wor