-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
snoop only in certain contexts #5
Comments
At least this sounds useful: def foo(i):
pp(i, when=i > 42) |
Why would you prefer that over |
I want to keep all debugging code self contained. There are cases, when I leave debugging code for several days, and once I come back to it, I want to clearly see, what is a debugging code and what is not. So at least this: if i > 42:
pp(i) Is not instantly clear if Turning it into one line helps a bit: if i > 42: pp(i) But I guess, I never write if statements in one line, so probably I will end up splitting it into two lines. Also I read from left to right, and it is quite possible, that because line starts with That is why, I prefer it to be self contained: pp(i, when=i > 4) Here I clearly know, that whole this line is just for debugging, and I can remove it without thinking. Also, this could be combined with pp(i, when=i > 4, context='debug') Also, if condition is passed to But I guess these are just my subjective personal preferences. |
Interesting. I think the benefit over an if statement is too small to justify the bloat in API and documentation. Maybe if other people are also interested in your API I'd consider it. What about context? Do you think you've had cases where that would have been useful? |
I never used anything similar to context, usually I get away with just if statements. |
Personally, I think this |
I think you're mixing up snoop and pp. |
Ops, yes, I mean snoop, not |
I still think you're confused. And |
I came across an interesting idea a debugging library called behold which might be nice for snoop. Suppose you have a function
foo()
which gets called in many places, but you only want to debug it when it gets called frombar()
. You could write:Or maybe the context depends on a condition:
Or (forgetting 'context' for a moment) the condition could be declared by
snoop
based on arguments:You might sometimes want to test for the context manually:
Lots of possibilities here. Does anyone think this kind of thing seems useful? Ideally, have you encountered any real use cases? Is it worth bloating the library? What would be a good API?
The text was updated successfully, but these errors were encountered: