Jun-03-2019, 01:13 AM
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?