unary star
Steven Taschuk
staschuk at telusplanet.net
Mon May 5 14:49:29 EDT 2003
Quoth David Eppstein:
> If f(a, b, *(c, d)) is always equivalent to f(a, b, c, d), then why
> isn't (a, b, *(c, d)) always equivalent to (a, b, c, d)?
>
> That is, since (non-keyworded) function arguments are a lot like tuples,
> why isn't there a unary star pseudo-operator to expand a sequence into
> the end of a tuple or list expression?
[...]
At first blush, I like the idea of unary * being more widely
applicable.
I see one difficulty: what if you want to expand a sequence of
sequences? That is, what if you have
S = ((c, d), (e, f))
and want to produce
(a, b, c, d, e, f)
? If unary * worked, this would (I presume) be
(a, b, **S)
which looks misleadingly like the **kwargs syntax. A reader might
expect that S is a dict. Moreover, you couldn't use this in a
function call; you'd have to add whitespace: * *S. Ick.
--
Steven Taschuk staschuk at telusplanet.net
"I'm always serious, never more so than when I'm being flippant."
-- _Look to Windward_, Iain M. Banks
More information about the Python-list
mailing list