"Bengt Richter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sat, 18 Dec 2004 03:05:08 -0500, "Terry Reedy" <[EMAIL PROTECTED]> > 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 -- http://mail.python.org/mailman/listinfo/python-list