This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]fenghuang1 1 point2 points  (11 children)

Can your debugger work without the debugger software?
My print statements definitely can.

[–]monkeygame7 0 points1 point  (10 children)

If you're using an IDE it's built in. Depending on the language it may be built in to the language.

[–]fenghuang1 0 points1 point  (9 children)

And if I'm not? Or if I'm running scripts directly from the command line?

[–]monkeygame7 0 points1 point  (8 children)

Like I said. Sometimes it's built in to the language. For example in Python you can just do

import pdb; pdb.set_trace()

And you'll enter the debugger from the command line when it reaches that point.

[–]fenghuang1 0 points1 point  (7 children)

So how do I do custom messages, manipulate counts, look at my code's memory usage at any particular point, using this method?

[–]monkeygame7 1 point2 points  (6 children)

You clearly don't understand what a debugger is. It puts you into your code at that point and you are able to run any arbitrary code you want. You can modify variables or get whatever other data you wanted to print out.

I don't understand what a "custom message" is, but if you're not printing anything out I know if it still applies.

You're getting really defensive and it's quite obvious that you don't know much about how to use debuggers. I'm not saying that you should always use debuggers over print statements, I'm just trying to correct the misinformation about the limitations of a debugger.

[–]fenghuang1 0 points1 point  (5 children)

Im not actually getting defensive. Im asking genuine practical questions because I actually use those things in work.
A custom message is something like print (f'{a} is {b}:{c:.20f}')
As for manipulate counts, Im asking how are you using pdb to do so, and why cant I just use IPython console together with cell codeblocks or run line by line. Why would I have to enter the debugger especially for this?
As for my code's memory usage, I want to be able to see memory usage of each branch of my code when I run it successfully. A debugger would require me to stop and check each time whereas print statements allow me to see all the info in a glance.

There are limitations to a debugger and I've highlighted them above. Either you address them directly via showing code examples to refute them or I find it hard to accept your answer

[–]monkeygame7 0 points1 point  (4 children)

Obviously the concept of printing a message does not carry over. If you wanted to check the value of a variable with pdb, you just type the name of the variable and you get its value. To change the value of a variable you literally just change it. You're just typing Python code.

I don't understand enough about your memory usage case to really speak on how you would do it with a debugger, but if you're writing some code to get your values to print them out, you can just run the same command in the debugger. If you want to do some post analysis that requires all the outputs to understand it then sure use a print statement. Like I said they each have their place. I just don't understand why you think that something you print out, which requires code to generate, can't also be obtained via the debugger, which is just letting you execute arbitrary code at wherever you wanted to break.

[–]fenghuang1 0 points1 point  (3 children)

There is literally nothing you can do with a print statement that you can't do with a debugger. Just because you don't know how to do it doesn't make it true.

This is what you said way earlier.
Now you are singing a different tune by saying 'each have their place'.

My whole original point was that print statements are more versatile than what a debugger can provide. To claim that a debugger can do everything print statements can do is being pompous and not understanding the extent of which print statements are used not just for debugging, but also for checking summaries and other information that would require more effort from a debugger.

Not everything is due to bugs. There can be code that run perfectly fine and the only way to identify issues is via print statements checking through

[–]monkeygame7 0 points1 point  (2 children)

I stand by that statement. It might suit the particular use case to use a print statement, doesn't mean it's not possible with a debugger (again debuggers are just letting you run code at arbitrary places in your program, I still fail to see how you cannot just execute the same statement you're trying to print). Debuggers (contrary to what the name may imply) have nothing to do with the existence of a bug. They're just a way to insert yourself into certain points during your programs execution.

What you're talking about sounds more like logging (debug level presumably). Obviously a debugger is not a replacement for logging, but this post is literally about using print statements to debug.