|
|
|
|
|
by tobik
3299 days ago
|
|
Bad example :) Most simple uses of lambda like this can be substituted with functions
from the operator module: import operator
formulas = {
'sum': operator.add,
'subst': operator.sub,
'mult': operator.mul,
'pow': operator.pow
}
|
|
However, what I meant was that for fast, quick coding, if your 'operator' function is really simple, then lambda fints perfectlu.
I know the Zen of Python says: "There should be one—and preferably only one—obvious way to do it", but i don't align to that principle. I think there should be more than one way to do something, and one should choose one that fits the best.