[Python-Dev] small Grammar questions
Steve Holden
steve at holdenweb.com
Wed Feb 20 03:15:35 CET 2008
Steve Holden wrote:
[...]
> The one that surprised me was the legality of
>
> def eggs((a, )=c):
> pass
>
> That just seems like unpacking-abuse to me.
>
Needless to say, a call that tries to *use* the default value fails
horribly, as the parameter form does require an iterable:
>>> def eggs((a, )=2.1):
... pass
...
>>> eggs()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in eggs
TypeError: 'float' object is not iterable
>>> eggs((2.1, ))
>>>
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-Dev
mailing list