On Tue, Oct 31, 2017 at 10:31:50AM +0000, אלעזר 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, = ...

with or without the parens. It would be terribly surprising if (x) was a 
sequence on the left hand side but not on the right hand side of an 
assignment.


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

a, (b, c), d = [1, "xy", 2]



> Currently
> 
>     (x) = 1
> 
> works, but I can't see why should it.

Why shouldn't it?

Its just a trivial case of the fact that the left hand side can be 
certain kinds of expressions, some of which require parens:

    (spam or ham)[x] = value

There are lots of possible expressions allowed on the LHS, and no good 
reason to prohibit (x) even though its pointless.



-- 
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to