Hello, On Mon, 21 Dec 2020 12:43:39 -0800 Christopher Barker <pythonchb@gmail.com> wrote:
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:
@TimeIt a_statement
into something like:
with TimeIt(): a_statement
Yes, that's it. It's all related to my earlier post on "dead simple import hooks" (which then can do transformations like that) https://mail.python.org/archives/list/python-ideas@python.org/thread/NIQQVA3... which in turn is related to the earlier discussion here https://mail.python.org/archives/list/python-ideas@python.org/thread/W2TMEUK... that anyone who has come up with a new syntactic/semantic idea for Python, should be easily enough able to implement it themselves (in pure Python), and be encouraged to do so. In this regard, I'm probing how my vision of implementation of that idea works with other people's ideas. As I mentioned, I don't consider statement-level annotations that useful (so far), but the point is that whoever has got such idea, should be able to try and play with it (and see in practice how useful it is). All that stuff is not ready for prime time yet, but as I mentioned that something works already here on the list, I now posted some early code also: https://github.com/pfalcon/python-imphook
-CHB
On Mon, Dec 21, 2020 at 12:24 PM Jonathan Fine <jfine2358@gmail.com> 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 time.sleep(1) ^ 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.
-- Jonathan -- Jonathan
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/KFO2HB... 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
-- Best regards, Paul mailto:pmiscml@gmail.com