annonymous functions -- how to

Scott David Daniels Scott.Daniels at Acm.Org
Fri May 6 12:16:15 EDT 2005


Fredrik Lundh wrote:
> 
> so name them all "func" or "next" or something, so you don't have
> to think.  once the object is bound, the name is irrlevant.
> 
Or, you could tell him about the reserved word anonymous which can be
used to created unnamed functions of values. A sample definition and
use of the anonymous keyword follows:

     def anonymous(text):
         return 'modified ' + text

     print 'Sample', anonymous('words')

--Scott David Daniels (with his tongue jammed firmly in his cheek)
Scott.Daniels at Acm.Org



More information about the Python-list mailing list