Draft Pep (was: Re: Let's Talk About Lambda Functions!)
Paddy
paddy3118 at tiscali.co.uk
Mon Aug 5 16:11:05 EDT 2002
I liked the PEP but thought the major use of indentation prior to
the def or class statement merited the inclusion of the usual
colon.
John Roth wrote:
<< SNIP>>
>>
>
> PEP: xxx
> Title: Anonymous Functions and Classes
> Version: $Revision: 1.0 $
> Last-Modified: $Date: 2002/08/03 16:23:15 $
> Author: John H. Roth <pythonstuff at jhrothjr.com>
> Status: Active
> Type: Standards Track
> Created: 03-Aug-2002
> Post-History:
>
>
> Abstract
>
> This PEP provides the syntax for generalized anonymous functions and
> classes. It provides a replacement for the lambda() function.
>
>
<<SNIP>>
>
>
> Specification
>
> An anonymous function or class consists of a parenthesized function
> or
> class definition, written the same way as a normal function or class
> definition, with the following exceptions.
<<INSERT>>
0. The enclosing left parenthesis should be followed immediately by
a colon, then optional whitespace, then a newline.
>
> 1. The name (the token immediately following the word def or class)
> is
> obviously omitted.
>
> 2. The 'def' or 'class' token must be on the line following the
> opening
> parenthesis.
>
> 3. The 'def' or 'class' token must be indented sufficiently for the
> ending
> right parenthesis to close the definition, and still continue the
> enclosing
> containing expression.
>
<<SUBSTITUTE THIS EXAMPLE FOR THE ORIGINAL BELOW>>
A very simple example:
x = (:
def (x, y):
print x
print y
)
> A very simple example:
> x = (
> def (x, y):
> print x
> print y
> )
>
> This example creates an anonymous function and then binds it to the
> variable x. If x was found within a class, it would be a method.
>
>
<<SNIP>>
What do you think of the proposed change John?
Paddy.
P.S.
I wonder? should you then be able to write `x = (: def (x): print x )` << Joke
Don't kill me for that last line :-)
More information about the Python-list
mailing list