Jonathan, did you notice:

python3 -m imphook -i mod_stmt_deco -m example_stmt_deco

I suspect mod_stmt_deco is some code that Paul wrote.

Guessing now, you can implement with with an import_hook, and I'm also guessing that that import hook translates:


into something like:

with TimeIt():


On Mon, Dec 21, 2020 at 12:24 PM Jonathan Fine <> wrote:
Hi Paul

I get a syntax error. The code won't even compile. I don't see how your code can avoid it. Are you sure your example works?

$ python3.8
Python 3.8.0 (default, Oct 28 2019, 16:14:01)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> @TimeIt
... time.sleep(1)
  File "<stdin>", line 2
SyntaxError: invalid syntax

By the way, I noticed that python 3.9 implements pep 614, but I don't see how that could allow your example to work.

If I've made a stupid mistake, please be kind to me.


Python-ideas mailing list --
To unsubscribe send an email to
Message archived at
Code of Conduct:

Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython