Revision: 21866
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 22, 2009 15:31 by magicrebirth
Initial Code
// add a function as an element of a dictionary >>> {1: lambda: len('ciao')} >>> {1: <function <lambda> at 0x101d530>} // get element with specified key >>> {1: lambda: len('ciao')}[1] >>> <function <lambda> at 0x101d5f0> >>> a = {1: lambda: len('ciao')}[1] >>> a >>> <function <lambda> at 0x101d670> // run the function-element >>> a() >>> 4 // or run it directly from here! >>> {1: lambda: len('ciao')}[1]() >>> 4
Initial URL
Initial Description
Initial Title
Python: lambda in a dictionary
Initial Tags
Initial Language
Python