better lambda support in the future?
bokr at oz.net
Sat Dec 18 21:43:13 CET 2004
On Sat, 18 Dec 2004 14:39:54 -0500, "Terry Reedy" <tjreedy at udel.edu> wrote:
>"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>
>>>To avoid the redundancy of 'a' and '_a', etc, how about (untested):
>>> dispatch[f.__name__.split('_')] = 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
>> 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 ;-)
More information about the Python-list