Xavier Ho wrote:
> I ran into a strange problem today: why does Python not allow default
> paranmeters for packed arguments in a function def?

>> >> def t(a, *b = (3, 4)):
>   File "<input>", line 1
>     def t(a, *b = (3, 4)):
>                 ^
> SyntaxError: invalid syntax

> What was the rationale behind this design?

Possibly because what you're calling 'packed arguments' are really
_arbitrary_ arguments, that is, it catches those that aren't defined
in the function signature. If you want default values, you should use
default arguments.

Of course, you can always get around it with this old chestnut:

    def t(a, *b):
      if not len(b): b = (3, 4)
      ...
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to