On Fri, 11 Feb 2005 07:35:43 +0100, Pierre Quentel <[EMAIL PROTECTED]> wrote: > Steven Bethard a écrit : > > Cappy2112 wrote: > > > >> What does the leading * do? > > > > > > Tells Python to use the following iterable as the (remainder of the) > > argument list: > > > > Could someone explain why this doesn't work : > > Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> def f(*args,**kw): > ... print args, kw > ... > >>> f(*[1,2]) > (1, 2) {} > >>> f(*[1,2],x=1) > File "<stdin>", line 1 > f(*[1,2],x=1) > ^ > SyntaxError: invalid syntax
the * and ** must occur at the end. f(x=1, *[1,2]) is valid. Stephen. -- http://mail.python.org/mailman/listinfo/python-list