Let's Talk About Lambda Functions!

Daniel Fackrell unlearned at DELETETHIS.learn2think.org
Tue Jul 30 09:36:09 EDT 2002


"John Roth" <johnroth at ameritech.net> wrote in message
news:ukb31ell2rh643 at news.supernews.com...

<snip>

>     for word in 'fee fie fo fum'.split():
>         Button(frame, command = def ():
>                 print word
>             )
>
> This isn't really the world's best example, because IMO, the
> lambda form is easier to read for something this small. However,
> it does give the guts of the idea:

<snip>

> 2. The remainder of the syntax exactly models def, including
> statement indentation within the expression. Notice that the
> first statement in the anonamous function has to be indented
> two from the preceeding line, because the continuation of
> the expression has to still be indented from the line with the
> 'def', and dedented from the statements.

IIRC, there's no such ting as "indenting two" in Python as the size of an
indentation is automatically detected as you go along, making the following
indentation style valid (although no one would ever want to do it):

toplevel
 secondlevel
                thirdlevel
 secondlevel
    thirdlevel
     fourthlevel
 secondlevel
toplevel

--
Daniel Fackrell (unlearned at learn2think.org)
When we attempt the impossible, we can experience true growth.





More information about the Python-list mailing list