Let's Talk About Lambda Functions!
johnroth at ameritech.net
Sat Aug 3 23:12:17 CEST 2002
"Huaiyu Zhu" <huaiyu at gauss.almadan.ibm.com> wrote in message
news:slrnakme8c.bn9.huaiyu at gauss.almadan.ibm.com...
> Bengt Richter <bokr at oz.net> wrote:
> >Just leave out the name after the def to make it anonymous,
> >and use parens to make the scope of the def expression obvious, e.g.,
> > x = y + (
> > def (z):
> > if z: return 'True z'
> > else: return 'False z'
> > )('arg for anonymous function') + ' & additional expression
> One problem of allowing intervening parens to adjust indentation is
> following is also a possibility
> x = y + (
> def (z):
> if z: return 'True z'
> else: return 'False z'
> )('arg for anonymous function') + ' & additional expression
As Bengt points out at more depth, this would be a syntax error,
because there is no dedent following the function. The next line after
else must be at the same or to the left of the def, which puts it to the
left of the expression, which is a syntax error.
The only way of making it not a syntax error is to indent reasonably.
More information about the Python-list