[Python-ideas] Positional only arguments
Aaron Brady
castironpi at comcast.net
Tue May 22 11:45:01 CEST 2007
> -----Original Message-----
> From: python-ideas-bounces at python.org [mailto:python-ideas-
> bounces at python.org] On Behalf Of Ron Adam
>
> def f(; a, b=2, c=3;): No positional only, no keyword only
Do you prohibit defaults in type 1, the pos-only?
Not necc. Does this look right?
>>> def f( a=0; b=1 ):
... print a, b
>>> f()
0, 1
Also, does this look right?
>>> def f( a=0; b ):
... print a, b
File "<stdin>", line 1
SyntaxError: non-default argument follows default argument
Any more groups? So far I have pos-only, pos-or-kw, and kw-only.
If not, a ascii character works fine to delimit, like * and **.
Do we want to annotate each parameter individually? This could get out of
hand. But decorators won't let you do
@f( k )
def j( k ):
...
where
@f( 'k' )
def j( k ):
...
gets unwieldy and could show promise. Cf. Steven's positional only
arguments decorator.
More information about the Python-ideas
mailing list