what is lambda used for in real code?

Terry Reedy tjreedy at udel.edu
Fri Dec 31 22:09:49 EST 2004


"Adam DePrince" <adam at cognitcorp.com> wrote in message 
news:1104531721.3724.18.camel at localhost.localdomain...
> In sort, we must preserve the ability to create an anonymous function
> simply because we can do so for every other object type, and functions
> are not special enough to permit this special case.

Please show me how to create an anonymous type, module, or class, 
especially with an expression.  Number, sequences, and dicts have easily 
printable values.  Functions, like classes and module do not*, so 
definition names act as a standin and as a pointer to the source code that 
produced the object.  If functions are not special relative to classes and 
modules, which is the grouping they belong with, then we should get rid of 
lambda ;-)

*Now that memory is 'cheap', someone recently proposed that code objects 
(and hence functions) get .source attribute.  Maybe, someday...

Terry J. Reedy






More information about the Python-list mailing list