4 ms·
This can sometimes be useful, though I haven't yet decided if I think it's a dirty hack or not. At one point, I made a timer whose __enter__ method started the
by MereInterest 4y ago
This can sometimes be useful, though I haven't yet decided if I think it's a dirty hack or not. At one point, I made a timer whose __enter__ method started the timer, and whose __exit__ method stopped the timer. After the "with", the elapsed time could be queried.
- masklinn 4y agoThat is used by several context managers, mostly those related to intercepting exceptions and warnings.
- andreareina 4y agoI feel like that would be better as t = timer() with t: ... (I've done this exact thing for this exact use-case)