prev | Version 1107 (Mon Nov 27 20:46:02 2006) | next |
WingIDE
in this lectureFigure 13.1: A Debugger in Action
Figure 13.2: Source Browser
Figure 13.3: Code Assistant
Microsoft Visual Studio
on WindowsEclipse
GDB
pdb
pdb.set_trace()
inside a programimport pdb base = "Na" pdb.set_trace() acid = "Cl" salt = base + acid print salt
$ python lec/inc/debugging/set_trace.py
> /swc/lec/inc/debugging/set_trace.py(7)?()
-> acid = "Cl"
(Pdb) n
> /swc/lec/inc/debugging/set_trace.py(8)?()
-> salt = base + acid
(Pdb) n
> /swc/lec/inc/debugging/set_trace.py(9)?()
-> print salt
(Pdb) n
NaCl
--Return--
Figure 13.4: Inspecting Values
2*x<0
, debugger displays False
Figure 13.5: Programs As Data
HALT
instructionFigure 13.6: Creating a Breakpoint
HALT
instruction, it signals the debuggerHALT
once againmax_temp
to -1)time_spent_waiting
to 600 seconds in debugger than to pull out the network cable and wait…None
DEBUG
: only want to see it when debugging a problemINFO
: information about normal operationsWARNING
: something that a human being should pay attention toERROR
: something has gone wrong inside the softwareCRITICAL
: something has gone very wrong inside the softwareWARNING
-level messages and above in a fileimport logging logging.basicConfig(level=logging.WARNING, format='%(asctime)s %(levelname)s %(message)s', datefmt='%Y-%b-%d %H:%M:%S', filename='logging_example.out', filemode='w') logging.debug('Last file opened: %s', datafile) logging.info('User %s logged in normally on %s', user_id, machine_name) logging.warning('%s attempted to log in as %s', villain, user_id) logging.error('No such spell (spell ID %04d)', spell_id) logging.critical('Failed to cast %s', curse)
2006-Feb-02 16:19:02 WARNING dmalfoy attempted to log in as hpotter 2006-Feb-02 16:19:02 ERROR No such spell (spell ID 0172) 2006-Feb-02 16:19:02 CRITICAL Failed to cast Confusius
assert
to check things that ought to be rightprev | Copyright © 2005-06 Python Software Foundation. | next |