[Python-ideas] Positional only arguments
Giovanni Bajo
rasky at develer.com
Fri May 18 01:58:31 CEST 2007
On 16/05/2007 16.50, George Sakkis wrote:
> 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've needed this only a few times, and I have used something like:
def foo(*args):
a,b,c = args
as a workaround. Doesn't look too clumsy after all.
For Py4k, the only thing that occurred to me is to reuse the parenthesis:
def foo((a, b, c, d), e, f, *, g, h):
pass
- a,b,c,d are positional-only
- e,f can be either positional or keyword
- g,h are only keyword.
--
Giovanni Bajo
More information about the Python-ideas
mailing list