unary star
Erik Max Francis
max at alcyone.com
Tue May 6 15:55:27 EDT 2003
David Eppstein wrote:
> 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)?
Because the * and ** syntaxes are specific to function calls; they're
shortcuts for apply. They are meant as inverses of the function
definition forms:
def f(x, y, *args, **keywords):
... # args is a tuple, keywords a dictionary
g(*args, **keywords) # same as apply(g, args, keywords)
In my opinion, the syntax should not generalize at all.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ To be adult is to be alone.
\__/ Jean Rostand
CatCam / http://www.catcam.com/
What do your pets do all day while you're at work? Find out.
More information about the Python-list
mailing list