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

Bruce Leban bruce at leapyear.org
Thu May 14 00:33:48 CEST 2009


Sure you can do it with a decorator. Although you might want one default to have this behavior and one not to. And putting the * right next to the lambda makes this a bit more explicit to my eye.

--- Bruce

Georg Brandl <g.brandl at gmx.net> wrote:

>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
>
>_______________________________________________
>Python-ideas mailing list
>Python-ideas at python.org
>http://mail.python.org/mailman/listinfo/python-ideas


More information about the Python-ideas mailing list