[Python-ideas] Fwd: Fwd: unpacking generalisations for list comprehension
אלעזר
elazarg at gmail.com
Sat Oct 15 13:38:32 EDT 2016
On Sat, Oct 15, 2016 at 8:36 PM Chris Angelico <rosuav at gmail.com> wrote:
> On Sun, Oct 16, 2016 at 4:33 AM, אלעזר <elazarg at gmail.com> wrote:
> > You are confusing here two distinct roles of the parenthesis:
> disambiguation
> > as in "(1 + 2) * 2", and tuple construction as in (1, 2, 3). This
> overload
> > is the reason that (1) is not a 1-tuple and we must write (1,).
>
> Parentheses do not a tuple make. Commas do.
>
> 1, 2, 3, # three-element tuple
> 1, 2, # two-element tuple
> 1, # one-element tuple
>
> And what [1, 2, 3] means? It's very different from [(1,2,3)].
Python explicitly allow 1, 2, 3 to mean tuple in certain contexts, I agree.
Elazar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161015/64ff2230/attachment.html>
More information about the Python-ideas
mailing list