I am aware of the partial function in functools, but how common is it in general python programs (not: Haskell, Erlang, Clojure etc ) to write functions to return functions in Python?
for example:
>>> def returnfunk(xs):
... return lambda x: list(filter(lambda y: x == y, xs))
...
>>> fn = returnfunk(["cat", "dog", "horse"])
>>>
>>> (fn("cow") == []) == True
True
>>> (fn("cat") == ['cat']) == True
True
>>>
>>> list(filter(fn, ["zebra", "elephant", "dog", "parrot", "cat"]))
['dog', 'cat']
is it meant for the real (python) world or more for hobby, academic, interest?
The decorators
@classmethodand@staticmethodare two examples.