3 ms·
No? The point is to factor out the repeated check-for-None code into one place to reduce redundancy and unclutter the algorithmic code in f. Separation of Conc
by Drbble 15y ago
No?
The point is to factor out the repeated check-for-None code into one place to reduce redundancy and unclutter the algorithmic code in f. Separation of Concerns.
- ehutch79 15y agoWriting wrapper functions that just calls a function provided as an argument seems insane to me. If the code really cares what it's getting, it should not only be checking for None, but also that the arguments it is called with are valid. I still fail to see why you would write a function like this at all.
- sophacles 15y agoMoving away from the trivial example used for simple demonstration purposes... Have you ever written validator code for your inputs from a web form? It really is the same pattern, usually implemented via decorator rather than direct result = validate(f, inputs) calls, but decorators are just syntactic sugar for that. Or are you really suggesting that every function which may take data from an input source copy and paste the same validation code to the top of that function?