Jim Jewett wrote: > On 4/19/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > >> Then you'd have: >> >> def f(a, *(b, c=1, *args), **(d, e=2, **kwds)): >> # Silly function >> >> 'a' would be a normal positional-or-keyword argument >> 'b' would be a required positional-only argument > > Am I reading that correctly? > > Looking only at a and b the possible calling signatures are exactly: > > f(1, 2) > f(a=1, 2) > > because b can't be named but must appear second, and nothing except a > can appear before it because of the rules on positional arguments.
Both would be illegal. The first one misses the required keyword argument 'd', the second one is a SyntaxError because you can't have a keyword argument before a positional one. Some legal combinations: f(1, 2, 3, d=1) # Positional args a, b and c f(1, 2, 3, 4, 5, 6, d=1) # Positional args a, b and c and (4, 5, 6) as args f(2, a=1, d=1) # Provide a as a keyword arg instead You'd never define a function with a signature as insane as the one in the example though - you'd only use it for cases where you accepted arbitray keyword arguments, but wanted to permit some positional arguments (like 'self') without accidental conflicts. This seems to be more of a theoretical problem than a practical one though. . . Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com