Draft Pep (was: Re: Let's Talk About Lambda Functions!)
paddy3118 at tiscali.co.uk
Mon Aug 5 22:11:05 CEST 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
John Roth wrote:
> 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
> This PEP provides the syntax for generalized anonymous functions and
> classes. It provides a replacement for the lambda() function.
> An anonymous function or class consists of a parenthesized function
> class definition, written the same way as a normal function or class
> definition, with the following exceptions.
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)
> obviously omitted.
> 2. The 'def' or 'class' token must be on the line following the
> 3. The 'def' or 'class' token must be indented sufficiently for the
> right parenthesis to close the definition, and still continue the
> containing expression.
<<SUBSTITUTE THIS EXAMPLE FOR THE ORIGINAL BELOW>>
A very simple example:
x = (:
def (x, 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.
What do you think of the proposed change John?
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