[Python-Dev] (no subject)

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Feb 11 06:17:31 CET 2015


Donald Stufft wrote:

> 1. The statement *item is roughly the same thing as (item[0], item[1], item[n])

No, it's not -- that would make it equivalent to tuple(item),
which is not what it means in any of its existing usages.

What it *is* roughly equivalent to is

    item[0], item[1], item[n]

i.e. *without* the parens, whatever that means in the
context concerned. In the context of a function call,
it has the effect of splicing the sequence in as if
you had written each item out as a separate expression.

You do have a valid objection insofar as this currently
has no meaning at all in a comprehension, i.e. this
is a syntax error:

    [item[0], item[1], item[n] for item in items]

So we would be giving a meaning to something that
doesn't currently have a meaning, rather than changing
an existing meaning, if you see what I mean.

-- 
Greg


More information about the Python-Dev mailing list