[Python-Dev] PEP 3102: Keyword-only arguments

BJörn Lindqvist bjourne at gmail.com
Sun May 7 13:29:53 CEST 2006


> > would have thought that the one obvious way to get rid of
> > the wanky feeling would have been to write:
> >
> > def make_person(name, age, phone, location): ...
> >
> > make_person(name, age, phone, location)
>
> This doesn't fly in something like PyGUI, where there
> are literally dozens of potential arguments to many
> of the constructors. The only sane way to deal with
> that is for them to be keyword-only, at least
> conceptually if not in actual implementation.

Probably. I don't know enough about library design in Python to
meaningfully criticize the Keyword-only arguments suggestion. However,
I do know enough about Python to know that the make_person function is
a really bad example. The one obvious way to write make_peson is to
use four positional arguments, name, age, phone, location and not
complicate the function by throwing in required keyword arguments. It
would be nice to instead see some real examples of the usefulness of
the required keyword-only arguments. Like from your PyGUI or maybe
from the standard library? But IMHO, your design is broken if you need
to send dozens of arguments to any function or method.

--
mvh Björn


More information about the Python-Dev mailing list