I downloaded and tried MacroPy today, with the thought that I would initially use it to trace execution of some code I was having trouble with. This is the first example shown on the PyPI page:
with trace:
sum([x + 5 for x in range(3)])
Not knowing any better, I tried this at the Python prompt:
import macropy.tracing
with trace:
sum([x + 5 for x in range(3)])
This, unfortunately fails:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: __exit__
Reading elsewhere later, I discovered that I was missing some other initialization, but I'm not entirely sure what that is. Assume I want to simply trace the body of a single function:
def f(a, b):
return a*5 + b / 7.0
If I don't want to disturb any other code, what do I need to do beyond this transformation?
def f(a, b):
from macropy.tracing import trace:
with trace:
return a*5 + b / 7.0
In fact, looking at the tracing examples in the doc:
https://github.com/lihaoyi/macropy#tracing (fourth example, "Lastly, trace can be used as a block macro") it appears I've done what I'm supposed to do. But clearly that is not enough. Shouldn't there be a "hello world" example which is complete in its entirety on PyPI or as part of the documentation?
Thanks,
Skip