[Python-ideas] Problems (and solutions?) in writing decorators

Christopher Barker pythonchb at gmail.com
Wed Mar 20 01:50:00 EDT 2019


def fun():

Is exactly the same as:

def fun()

fun = something(fun)

So you can’t make a distinction based whether a given usage  is as a


On Tue, Mar 19, 2019 at 12:26 PM Greg Ewing <greg.ewing at canterbury.ac.nz>

> Sylvain MARIE via Python-ideas wrote:
> > `my_decorator(foo)` when foo is a callable will always look like
> > `@my_decorator` applied to function foo, because that's how the language
> is
> > designed.
> I don't think it's worth doing anything to change that. Everywhere
> else in the language, there's a very clear distinction between
> 'foo' and 'foo()', and you confuse them at your peril. I don't see
> why decorators should be any different.
> --
> Greg
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190319/a31d1a3d/attachment.html>

More information about the Python-ideas mailing list