[Texas] PyTexas 2010 proposal: Debugging in Python
J. Cameron Cooper
jccooper at gmail.com
Fri Jul 16 00:22:27 CEST 2010
.. Proposal submission for PyTexas 2010
.. Waco, TX Aug 28, 2010
.. Template uses reStructuredText format:
http://docutils.sourceforge.net/rst.html
Debugging in Python
===================
:Type: hands-on tutorial
:Presenter: J Cameron Cooper <jcc at jcameroncooper.com>
:Python level: beginner to intermediate
Description
-----------
Learn to love (and use) the cryptic but incredibly useful 'pdb' module. Try
the three different
ways to get into the debugger, insert breakpoints, step through code,
examine and move up and
down the stack, and more. Also, working in the interactive interpretter and
using the 'logging'
module.
Extended description
--------------------
This session will help any Python progammer learn some basic but non-obvious
tools of the trade,
specifically the interactive debugger and logging. Mostly for beginners and
others who've never
gotten into pdb, but those with only limited pdb usage may also benefit.
Rather than a talk, I plan to have everyone do it themselves, which should
provide for better learning.
I will provide some simple programs to debug, and walk through the most
useful
techniques of pdb and friends. Probably will not be able to cover all the
commands in time allotted,
but should be able to get all the important stuff.
Outline
-------
I. How are you debugging?
a. Staring at it?
b. Print?
1. watch out for Python 3
c. Interactive Console (if you didn't know...)
II. A better way: pdb
a. Get some code to debug
b. pdb reference online, and other good articles
c. Get into pdb session the easiest way: pdb.set_trace()
1. how it works and what we can do
2. interactive help with 'help'
3. leaving with 'quit'
4. repeating with blank lines
d. Examine the environment
1. show location with 'list'
2. print values with 'p' (and whithout)
3. see args with 'args'
4. execute statements
5. look at stack with 'where'
e. Move around
1. go forward with 'step', 'next'
2. fast-forward with 'return', 'continue', and 'until'
3. go back with 'jump'
f. The stack
1. printing the stack with 'where'... and what it means
2. navigating the stack with 'up' and 'down'
g. Other ways into pdb
1. multple 'set_trace'
2. after a crash: post-mortem with 'pm' and 'post_mortem'
a. interactive
b. as exception handling
3. without error or source changes: 'run', 'runeval', and 'runcall'
a. setting breakpoints with 'break' and 'tbreak'
b. managing breakpoints with 'clear', 'disable', 'enable'
c. skipping breakpoints with 'condition' and 'ignore'
d. hooking into breakpoints with 'commands'
e. restarting with 'run'
III. Logging
a. When it's useful - production and tight loops
b. Get some code to log
c. logging reference online
d. use with Zope (and other frameworks)
e. configure logging
i. default location
ii. to a file
iii. changing levels
f. place statements in code
g. advanced logging options
Bio
---
J Cameron Cooper is an independent web developer (and sometimes trainer)
specializing in
Plone, Zope, and Python. He threw off the shackles of Algol-derived
languages and began
working with Python when Zope 1.10 came out in 1999. He has worked for
Enfold Systems as
developer, consultant, and trainer, and for Connexions (cnx.org) as System
Architect and
developer--both major Plone and Python users. He is the author of "Building
Websites with Plone"
from Packt Publishing. He is a graduate of Rice University with degrees in
Computer Science
and History.
Recording release
-----------------
I will sign the recording release agreement (text at
http://pytexas.org/RecordingRelease).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/texas/attachments/20100715/3cb417ee/attachment.html>
More information about the Texas
mailing list