[Python-ideas] Default arguments in Python - the return - running out of ideas but...
Bruce Leban
bruce at leapyear.org
Thu May 14 00:04:05 CEST 2009
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. This is equivalent to:
__unset = object()
__default = lambda: expression
def mfunc(a, b, c = __unset):
if c == __unset:
c = __default()
stuff
--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20090513/82e61141/attachment.html>
More information about the Python-ideas
mailing list