Skip to content
Advertisement

Tag: debugging

Python: Print a variable’s name and value?

When debugging, we often see print statements like these: How can write a function that will take a variable or name of a variable and print its name and value? I’m interested exclusively in debugging output, this won’t be incorporated into production code. Answer You can just use eval: Or more generally (which actually works in the context of the

Ran Pycharm debug which ended with exit code -1

Just a quick question but I ran Pycharm debug on a lengthy series of test scripts and the end result was: I was just wondering what this means given that exit code 0 is a pass and exit code 1 is a fail. (is it super awesome code to end in -1?) Answer You may be seeing that exit code

Check how many times a string appears in a particular word

I am practicing my python coding on this website. This is the problem This is my code , for some unknown reason , i dont pass all the testcases. I have problems debugging it Answer You don’t need to creat a function,just a line is enough.like: return s.count(‘cat’) == s.count(‘dog’)

Extract traceback info from an exception object

Given an Exception object (of unknown origin) is there way to obtain its traceback? I have code like this: How can I extract the traceback from the Exception object once I have it? Answer The answer to this question depends on the version of Python you’re using. In Python 3 It’s simple: exceptions come equipped with a __traceback__ attribute that

Memory dump formatted like xxd from gdb

I’m trying to inspect a buffer which contains a binary formatted message, but also contains string data. As an example, I’m using this C code: I’d like to get a hex dump of what’s in buf, of a format similar to xxd (I don’t care if it’s an exact match, what I’m really looking for is a hex dump side

Advertisement