[Python-Dev] (no subject)
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Feb 10 06:55:20 CET 2015
Donald Stufft wrote:
> However [*item for item in ranges] is mapped more to something like this:
>
> result = []
> for item in iterable:
> result.extend(*item)
Actually it would be
result.extend(item)
But if that bothers you, you could consider the expansion
to be
result = []
for item in iterable:
for item1 in item:
result.append(item)
In other words, the * is shorthand for an extra level
of looping.
> and it acts differently than if you
> just did *item outside of a list comprehension.
Not sure what you mean by that. It seems closely
analogous to the use of * in a function call to
me.
--
Greg
More information about the Python-Dev
mailing list