Here is something that surprised me tonight:
[color=blue][color=green][color=darkred]
>>> def myfunc(x, y, a='A', *mylist):[/color][/color][/color]
print x
print y
print a
for item in mylist:
print item
[color=blue][color=green][color=darkred]
>>> myfunc(2, 5, 6, 7, 8)[/color][/color][/color]
2
5
6
7
8[color=blue][color=green][color=darkred]
>>> myfunc(1, 2)[/color][/color][/color]
1
2
A[color=blue][color=green][color=darkred]
>>> myfunc(1, 2, 3, 4, 5)[/color][/color][/color]
1
2
3
4
5[color=blue][color=green][color=darkred]
>>> def myfunc(x, y, *mylist, a='A'):[/color][/color][/color]
SyntaxError: invalid syntax
Why isn't the default value for a printing out when I include list
arguments?
(This is Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on
win32, if that makes a difference.)
I would suspect at first a Python bug, but maybe I'm just not "seeing"
something that I should?
--
Sheila King
[color=blue][color=green][color=darkred]
>>> def myfunc(x, y, a='A', *mylist):[/color][/color][/color]
print x
print y
print a
for item in mylist:
print item
[color=blue][color=green][color=darkred]
>>> myfunc(2, 5, 6, 7, 8)[/color][/color][/color]
2
5
6
7
8[color=blue][color=green][color=darkred]
>>> myfunc(1, 2)[/color][/color][/color]
1
2
A[color=blue][color=green][color=darkred]
>>> myfunc(1, 2, 3, 4, 5)[/color][/color][/color]
1
2
3
4
5[color=blue][color=green][color=darkred]
>>> def myfunc(x, y, *mylist, a='A'):[/color][/color][/color]
SyntaxError: invalid syntax
Why isn't the default value for a printing out when I include list
arguments?
(This is Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on
win32, if that makes a difference.)
I would suspect at first a Python bug, but maybe I'm just not "seeing"
something that I should?
--
Sheila King
Comment