better lambda support in the future?

Terry Reedy tjreedy at udel.edu
Sat Dec 18 20:39:54 CET 2004


"Bengt Richter" <bokr at oz.net> wrote in message 
news:41c3ea9c.371195651 at news.oz.net...
> On Sat, 18 Dec 2004 03:05:08 -0500, "Terry Reedy" <tjreedy at udel.edu> 
> 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 
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 
postings.

Terry J. Reedy






More information about the Python-list mailing list