pdb

How to print all variables values when debugging Python with pdb, without specifying each variable?

主宰稳场 提交于 2019-12-02 14:22:11
I'm debugging my Python scripts using pdb and the manual says I can use p variables command to print the values of the specified variables at a certain point. But what if I had lots of variables, like 20 variables, and I would like to track the value of all of them? How do I print all of them without specifying each one manually? Take for example this script: a = 1 b = 2 c = 3 I can debug it with pdb and print all of them using p a, b, c like this: $ python -m pdb test.py > /media/test.py(1)<module>() -> a = 1 (Pdb) n > /media/test.py(2)<module>() -> b = 2 (Pdb) n > /media/test.py(3)<module>()

Debugging python programs in emacs

我与影子孤独终老i 提交于 2019-12-02 14:12:05
How to debug python programs in emacs? I use python-mode.el I get reference like import pdb; pdb.set_trace(); but not sure how to use it. Type M-x cd to change directory to the location of the program you wish to debug. Type M-x pdb . You'll be prompted with Run pdb (like this): pdb . Enter the name of the program (e.g. test.py ). At the (Pdb) prompt, type help to learn about how to use pdb. Alternatively, you can put import pdb pdb.set_trace() right inside your program (e.g. test.py ). Now type M-x shell to get a shell prompt. When you run your program, you'll be dumped into pdb at the point

Tracing the execution of a Python program line/statement by line programmatically

扶醉桌前 提交于 2019-12-02 08:44:44
问题 What would be the easiest way to execute a Python script and, for each executed statement, pass the line number or the line itself to a callback function? For example A piece of code to be executed for i in range(5): z = i**2 and a callback def callback(line): print line The output would be: for i in range(5): z = i**2 for i in range(5): z = i**2 for i in range(5): z = i**2 ... etc Another way of stating this is that I want to know the piece of code that would be next to execute if I were

Tracing the execution of a Python program line/statement by line programmatically

旧巷老猫 提交于 2019-12-02 07:09:01
What would be the easiest way to execute a Python script and, for each executed statement, pass the line number or the line itself to a callback function? For example A piece of code to be executed for i in range(5): z = i**2 and a callback def callback(line): print line The output would be: for i in range(5): z = i**2 for i in range(5): z = i**2 for i in range(5): z = i**2 ... etc Another way of stating this is that I want to know the piece of code that would be next to execute if I were running the script stepping through a debugger.. I've seen this question about tracing but I'm interested

Variable alternates whether or not it exists in Python Debugger

╄→гoц情女王★ 提交于 2019-12-02 05:57:35
问题 Can anyone explain this? (Python 2.7, Django 1.7) foo = data['selected_items'] (Pdb) foo (Pdb) *** NameError: name 'foo' is not defined foo (Pdb) u'1,2' foo (Pdb) *** NameError: name 'foo' is not defined foo (Pdb) u'1,2' foo (Pdb) *** NameError: name 'foo' is not defined foo (Pdb) u'1,2' Here is the view function that triggered it: def process_form(request, model_name): form = BulkEditForm(request.POST) if form.is_valid(): data = form.clean() if data['select_all']: pass else: import pdb; pdb

In pdb (python debugger), can I set a breakpoint on a builtin function?

半城伤御伤魂 提交于 2019-12-01 22:08:39
问题 I want to set a breakpoint on the set.update() function, but when I try, I get an error message. Example: ss= set() ss.update('a') Breakpoint: b set.update b ss.update Errors: The specified object 'ss.update' is not a function or was not found along sys.path. The specified object 'set.update' is not a function or was not found along sys.path. (Note, I also tried with the parentheses at the end, e.g., b set.update() , but still got the error. I didn't print all the permutations of errors.) 回答1

In pdb (python debugger), can I set a breakpoint on a builtin function?

℡╲_俬逩灬. 提交于 2019-12-01 21:31:14
I want to set a breakpoint on the set.update() function, but when I try, I get an error message. Example: ss= set() ss.update('a') Breakpoint: b set.update b ss.update Errors: The specified object 'ss.update' is not a function or was not found along sys.path. The specified object 'set.update' is not a function or was not found along sys.path. (Note, I also tried with the parentheses at the end, e.g., b set.update() , but still got the error. I didn't print all the permutations of errors.) Thanks! Using @avasal's answer and Doug Hellmann's pdb webpage , I came up with this: Since I was trying

pdb file is mising after PostSharp

∥☆過路亽.° 提交于 2019-12-01 16:53:38
I am using PostSharp version 2.1.6.4 (also tried latest version 2.1.7.35) and sometimes pdb file is missing and there is a pssym file in it's place. <?xml version="1.0" encoding="utf-8"?> <Symbols xmlns="http://schemas.postsharp.org/2.0/symbols"> <Class Class="#1=T:[CrosscuttingLogging]CrosscuttingLogging.Attributes.LogMethodCallStatsAttribute" LimitedLicense="true" /> <Class Class="#2=T:[RequestLimiter]RequestLimiter.RequestCounterAttribute" LimitedLicense="true" /> </Symbols> I ran procmon on the build process and as far as I can tell the postsharp.srv.4.0-x86.exe process moves both dll and

'n' in pdb moves me inside of the pdb.set_trace() method

≡放荡痞女 提交于 2019-12-01 16:53:34
I'm trying to learn pdb using this tutorial referenced from another stackoverflow question , and I'm on the 3rd step of the Getting Started section. In [12]: %paste # epdb1.py -- experiment with the Python debugger, pdb import pdb a = "aaa" pdb.set_trace() b = "bbb" c = "ccc" final = a + b + c print final ## -- End pasted text -- --Return-- > <ipython-input-12-48afa1c7ad72>(4)<module>()->None -> pdb.set_trace() (Pdb) l 1 # epdb1.py -- experiment with the Python debugger, pdb 2 import pdb 3 a = "aaa" 4 -> pdb.set_trace() 5 b = "bbb" 6 c = "ccc" 7 final = a + b + c 8 print final [EOF] (Pdb) n >

'n' in pdb moves me inside of the pdb.set_trace() method

こ雲淡風輕ζ 提交于 2019-12-01 15:30:35
问题 I'm trying to learn pdb using this tutorial referenced from another stackoverflow question, and I'm on the 3rd step of the Getting Started section. In [12]: %paste # epdb1.py -- experiment with the Python debugger, pdb import pdb a = "aaa" pdb.set_trace() b = "bbb" c = "ccc" final = a + b + c print final ## -- End pasted text -- --Return-- > <ipython-input-12-48afa1c7ad72>(4)<module>()->None -> pdb.set_trace() (Pdb) l 1 # epdb1.py -- experiment with the Python debugger, pdb 2 import pdb 3 a =