[Python-ideas] Default arguments in Python - the return - running out of ideas but...

Georg Brandl g.brandl at gmx.net
Thu May 14 00:20:46 CEST 2009


Bruce Leban schrieb:
> Here's what I'd like:
> 
> def myfunc(a, b, c = *lambda: expression):
>   stuff
> 
> The use of the lambda keyword here makes the scope of any variables in
> the expression clear. The use of the prefix * makes the syntax invalid
> today, suggests dereferencing and doesn't hide the overhead.

Why not

@calldefaults
def myfunc(a, b, c = lambda: expression):
    pass

which should be possible without introducing new syntax.

Georg




More information about the Python-ideas mailing list