On 4 July 2013 04:52, Maciej Dziardziel <fied...@gmail.com> wrote: > Out of curiosity: Does anyone know why the code below is valid in python3, > but not python2: > > def foo(*args, bar=1, **kwargs): > pass
Python 3 gained syntax for keyword-only arguments. Try "foo(1)" and it will fail -- "bar" needs to be given as a keyword. This is because it comes after a *-expression. You can also do "def foo(*, bar=1)" if you want bar to be keyword-only without accepting any number of positional arguments. Python 2 does not have these, and doesn't understand the syntax for them. -- http://mail.python.org/mailman/listinfo/python-list