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

אלעזר elazarg at gmail.com
Tue Oct 31 06:31:50 EDT 2017


On Tue, Oct 31, 2017 at 12:18 PM Koos Zevenhoven <k7hoven at gmail.com> wrote:

> On Tue, Oct 31, 2017 at 11:24 AM, Petr Viktorin <encukou at gmail.com> 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 (unfortunately) several ways to do it. I prefer one that avoids
>> a trailing comma:
>>
>> [the_bob] = ​(name for name in ('bob','fred') if name=='bob')
>>
>>
> ​Maybe it's just me, but somehow that list-like syntax as an assignment
> target feels wrong in somewhat the same way that (1, 2).append(3) does.​
>
>
Off topic: why can't we simply allow something like this:

    (the_bob) = (name for name in ('bob','fred') if name=='bob')

Why does Python treat the parenthesis at the LHS as grouping parens?
operators are not allowed anyway; (a + (b + c)) = [1] is syntax error.

Currently

    (x) = 1

works, but I can't see why should it.

Elazar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171031/d84a0b69/attachment.html>


More information about the Python-ideas mailing list