On 4/18/2010 7:23 PM, Xavier Ho wrote:
G'day Pythoneers,

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

>> def test(a = 1, b = (2, 3)):
...     print a, b
...
>> test()
1 (2, 3)

>> 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?

To reword what G. Ewing said, because t(3) causes b to be empty. In actually use cases, I believe that that is usually the appropriate thing to do.

tjr

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to