better lambda support in the future?

Bengt Richter bokr at
Sat Dec 18 21:43:13 CET 2004

On Sat, 18 Dec 2004 14:39:54 -0500, "Terry Reedy" <tjreedy at> wrote:

>"Bengt Richter" <bokr at> wrote in message 
>news:41c3ea9c.371195651 at
>> On Sat, 18 Dec 2004 03:05:08 -0500, "Terry Reedy" <tjreedy at> 
>> wrote:
>>>To avoid the redundancy of 'a' and '_a', etc, how about (untested):
>>>def dispvia(f):
>>>  dispatch[f.__name__.split('_')[1]] = f
>>>  return f
>> That should work. Didn't want to retype ;-) I just wanted to get
>> to the experiment following -- did you notice that it takes the 
>> assignment
>> name from each "def dispatch ...", but it is actually re-assigning the 
>> returned dispatch
>> *dict* as the value, not a modified function?
>Yes, I noticed that your second version of dispvia, which I snipped, 
>returned dispatch instead of the nested function named _.   But I did not 
That's actually not the right "instead" ;-) I.e., the function _ returns
dispatch instead of the function passed to _it_ for deco-modification.

>quite think thru the import of so doing.
>I think one or more of these recipies might at least be worthy of the 
>cookbook site so they can be easily referenced in response to future 
It is a little sneaky though, so it might not be prudent to promote
without a little more experimentation? I just like to explore ;-)

Bengt Richter

More information about the Python-list mailing list