function call - default value & collecting arguments
Terry Reedy
tjreedy at udel.edu
Wed Apr 2 15:33:05 EDT 2008
"Primoz Skale" <primoz.skale.lists at gmail.com> wrote in message
news:_LQIj.9776$HS3.482805 at news.siol.net...
| def f(*a=(0,)):
| print a[0] #this should come next, but we get error msg instead, saying
|
| SyntaxError: invalid syntax
|
| but it does not work this way. Now my 'newbie' question: Why not? :)
Possibly because no one ever thought of that.
More likely because it is contradictory: by definition, *a *always* gets a
value, so there is never a need for a 'default'. When a param gets a value
you don't like, you have to explicitly replace it or whatever.
So add at the top 'a = a or (0,)'
tjr
More information about the Python-list
mailing list