Have do_nothing as default action for dictionary?

Christopher Reimer christopher_reimer at yahoo.com
Sun Sep 3 19:15:28 EDT 2017


Greetings,

After reading everyone's comments and doing a little more research, I 
re-implemented my function as a callable class.

     def __call__(self, key, value):
         if key not in self._methods:
             return value
         return self._methods[key](value)

This behaves like my previous function, solved the problem that I had 
with the dictionary, the dictionary is created only once, a half dozen 
functions got moved into the new class, and the old class now has less 
clutter.

Thanks everyone!

Chris R.



More information about the Python-list mailing list