Howdy all,

I want an explicit replacement for a common decorator idiom.

There is a clever one-line decorator that has been copy-pasted without
explanation in many code bases for many years::

    decorator_with_args = lambda decorator: lambda *args, **kwargs: lambda 
func: decorator(func, *args, **kwargs)

My problem with this is precisely that it is clever: it explains nothing
about what it does, has many moving parts that are not named, it is
non-obvious and lacks expressiveness.

Even the widely-cited ActiveState recipe by Peter Hunt from 2005
<URL:http://code.activestate.com/recipes/465427-simple-decorator-with-arguments/>
gives no clue as to what this is doing internally nor what the names of
its parts should be.

I would like to see a more Pythonic, more explicit and expressive
replacement with its component parts easily understood.

-- 
 \     “[H]ow deep can a truth be — indeed, how true can it be — if it |
  `\             is not built from facts?” —Kathryn Schulz, 2015-10-19 |
_o__)                                                                  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to