Re:Show HN: Laboratory, a Python port of GitHub's Scientist ...
by shoyer on Monday February 15, 2016 @10:26PM
(#11107714)
Agreed -- a decorator seems like a much cleaner way to handle this.
[ Parent
| on HN ]
Re:Show HN: Laboratory, a Python port of GitHub's Scientist ...
by msellout on Tuesday February 16, 2016 @12:22AM
(#11108047)
A decorator must be applied to a function or class, whereas a context manager can wrap an arbitrary section of code. So, it depends on how you want the tool to be used. I don't think there's a clear best design.
Re:Show HN: Laboratory, a Python port of GitHub's Scientist ...
by buttscicles on Tuesday February 16, 2016 @04:49AM
(#11108834)
This was my thought as well, and it's also a bit more awkward if your function signatures differ. Luckily they aren't mutually exclusive and it should be easy to implement a decorator version.