On Tue, Oct 31, 2017 at 12:18 PM Koos Zevenhoven <k7ho...@gmail.com> wrote:
> On Tue, Oct 31, 2017 at 11:24 AM, Petr Viktorin <encu...@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
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/