4 ms·
Some of these things look really nice. I'm particularly impressed by the tracing macro: with trace: sum = 0 for i in range(0, 5):
by davidshepherd7 11y ago
Some of these things look really nice. I'm particularly impressed by the tracing macro:
with trace:
sum = 0
for i in range(0, 5):
sum = sum + 5
prints
sum = 0
for i in range(0, 5):
sum = sum + 5
range(0, 5) -> [0, 1, 2, 3, 4]
sum = sum + 5
sum + 5 -> 5
sum = sum + 5
sum + 5 -> 10
sum = sum + 5
sum + 5 -> 15
sum = sum + 5
sum + 5 -> 20
sum = sum + 5
sum + 5 -> 25
This would save a huge amount of boring typing `print(...)` when debugging,
and since it's only for debugging you don't even need to have MacroPy as a
dependency!
Unfortunately python 3.4 support is not quite ready [0], and attempting to
install it with `pip3` just fails.
[0]: https://github.com/lihaoyi/macropy/issues/32 https://github.com/lihaoyi/macropy/issues/32
- scrollaway 11y agoCan I recommend the wonderful `q`? https://pypi.python.org/pypi/q https://pypi.python.org/pypi/q "import q; q(var1, var2)" forces printing to $TMPDIR/q (usually /tmp/q) very detailed output of what you are tracing and what it is. The @q decorator does somewhat the same as the "with trace" context manager.
- davidshepherd7 11y agoIt seems nice, but not quite as powerful. I like the way the tracing macro automatically prints every intermediate value, but q doesn't seem to do that.
- nomel 11y agoThe real question is, why are you using print statements to debug?