[Python-ideas] Positional only arguments
Ron Adam
rrr at ronadam.com
Fri May 18 04:10:05 CEST 2007
George Sakkis wrote:
> This was posted on python-dev two weeks ago [1] but didn't get very
> far; probably python-ideas is a more appropriate list if this is to be
> taken any further.
>
> In short, PEP 3102 enables the declaration of keyword-only arguments,
> making it easier for an API to grow in a backwards compatible way. As
> Benji York, I see the utility of positional-only arguments, not just
> for the sake of symmetry but for pragmatic reasons; in fact the same
> reasons that serve as rationale to the keywords-only PEP.
>
> I don't have any concrete proposal (syntactic or otherwise) at this
> point, but I'd like to see this feature in Py3K even if I dislike the
> specific syntax or other machinery that implements it (just like
> decorators). For now it's worth just getting an idea of whether the
> feature itself is deemed useful enough or the current status quo is
> adequate.
>
> George
>
>
> [1] http://mail.python.org/pipermail/python-dev/2006-May/064790.html
It seems there is a growing menu of arguments options. I suppose that's a
good thing. As long as it doesn't get too confusing.
Another thing I've wished I had recently is a way to over specify an
argument list by giving it a larger list of arguments (or keywords) than is
needed.
For example if I'm dispatching a collection of functions that each have
different set or number of arguments, I'd like to say on the calling end
for the function to take what it needs from a list and/or dictionary, but
ignore what it doesn't need.
In the case of positional only arguments, it could take them in order, and
in the case of keywords only, by name. The point is to be able to specify
it from the calling end in a generic way instead of having to do it inside
the function or by adding a decorator to each function. It's kind of like
an simplified or generic adapter in a way.
Cheers,
Ron
More information about the Python-ideas
mailing list