Python debug

Python Debugger:

Recently i came to know that The most important things to be a Great programmer,not only to know the programming..knowing the debugging is makes this as a great programmer from quora and swaroop

So,Certainly I was searching about debugging in python.

>>>import pdb

python debugger package to debug your python gold code.

>>>pdb.set_trace()

This line you need to add where you want to start debugging.

Absolutely we can debug

>>>pdb.run(“string function object”)//function object as a string

There are pretty lot of options and commands are there to do debugging.

The debugging shell looks like

> /work/t/rec.py(12)recursive_fn()
-> return
(Pdb) args
n = 3
output = to print
(Pdb)

The command options in the debugging shell:

list

list the lines where the current call stack is processing

step

Next line to be debugged

next,until,up,down…

These are the commands which does the operation according to it’s meaning.

p var

print var(var means variable)

p var1,var2,var2

pp var

pprint variables by comma seperator

where

current call stack

If you want assign a value for a variable in the debugging shell

You have to use the (!) exclamatory mark

!var = value

These won’t throw exception related to object

These are the basic skills i touched today

If you need elaborately go ahead with these

http://www.doughellmann.com/PyMOTW/pdb/

Advertisements

About Navaneethan

mixed feelings...
This entry was posted in General. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s