Jun-03-2019, 01:13 AM
(This post was last modified: Jun-03-2019, 01:14 AM by ichabod801.)
So, say you are passing around callables to functions. Say also that you could do this with something from the operator package. Would you create a lambda to do it, or use operator?
For example, I have this function specification:
For example, I have this function specification:
def ask_valid(self, prompt, valid, default = '', conversion = lambda choice: choice.lower()):But I was thinking of rewriting it this way:
def ask_valid(self, prompt, valid, default = '', conversion = operator.methodcaller('lower')):Do you have a preference? Any particular reason for that preference?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures