Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 25f6fcc

Browse files
committed
more complete examples
1 parent 93dda33 commit 25f6fcc

2 files changed

Lines changed: 46 additions & 18 deletions

File tree

Doc/lib/libpdb.tex

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ \chapter{The Python Debugger}
1212
under program control.
1313

1414
The debugger is extensible --- it is actually defined as a class
15-
\code{Pdb}. The extension interface uses the (also undocumented)
16-
modules \code{bdb} and \code{cmd}; it is currently undocumented but
17-
easily understood by reading the source.
15+
\code{Pdb}. This is currently undocumented but easily understood by
16+
reading the source. The extension interface uses the (also
17+
undocumented) modules \code{bdb} and \code{cmd}.
1818
\ttindex{Pdb}
1919
\ttindex{bdb}
2020
\ttindex{cmd}
@@ -25,13 +25,20 @@ \chapter{The Python Debugger}
2525
\index{stdwin}
2626
\ttindex{wdb}
2727

28+
The debugger's prompt is ``\code{(Pdb) }''.
2829
Typical usage to run a program under control of the debugger is:
2930

3031
\begin{verbatim}
3132
>>> import pdb
3233
>>> import mymodule
3334
>>> pdb.run('mymodule.test()')
34-
(Pdb)
35+
> <string>(0)?()
36+
(Pdb) continue
37+
> <string>(1)?()
38+
(Pdb) continue
39+
NameError: 'spam'
40+
> <string>(1)?()
41+
(Pdb)
3542
\end{verbatim}
3643

3744
Typical usage to inspect a crashed program is:
@@ -40,13 +47,19 @@ \chapter{The Python Debugger}
4047
>>> import pdb
4148
>>> import mymodule
4249
>>> mymodule.test()
43-
(crashes with a stack trace)
50+
Traceback (innermost last):
51+
File "<stdin>", line 1, in ?
52+
File "./mymodule.py", line 4, in test
53+
test2()
54+
File "./mymodule.py", line 3, in test2
55+
print spam
56+
NameError: spam
4457
>>> pdb.pm()
45-
(Pdb)
58+
> ./mymodule.py(3)test2()
59+
-> print spam
60+
(Pdb)
4661
\end{verbatim}
4762

48-
The debugger's prompt is ``\code{(Pdb) }''.
49-
5063
The module defines the following functions; each enters the debugger
5164
in a slightly different way:
5265

@@ -111,7 +124,8 @@ \section{Debugger Commands}
111124
statements and are executed in the context of the program being
112125
debugged. Python statements can also be prefixed with an exclamation
113126
point (``\code{!}''). This is a powerful way to inspect the program
114-
being debugged; it is even possible to change variables. When an
127+
being debugged; it is even possible to change a variable or call a
128+
function. When an
115129
exception occurs in such a statement, the exception name is printed
116130
but the debugger's state is not changed.
117131

Doc/libpdb.tex

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ \chapter{The Python Debugger}
1212
under program control.
1313

1414
The debugger is extensible --- it is actually defined as a class
15-
\code{Pdb}. The extension interface uses the (also undocumented)
16-
modules \code{bdb} and \code{cmd}; it is currently undocumented but
17-
easily understood by reading the source.
15+
\code{Pdb}. This is currently undocumented but easily understood by
16+
reading the source. The extension interface uses the (also
17+
undocumented) modules \code{bdb} and \code{cmd}.
1818
\ttindex{Pdb}
1919
\ttindex{bdb}
2020
\ttindex{cmd}
@@ -25,13 +25,20 @@ \chapter{The Python Debugger}
2525
\index{stdwin}
2626
\ttindex{wdb}
2727

28+
The debugger's prompt is ``\code{(Pdb) }''.
2829
Typical usage to run a program under control of the debugger is:
2930

3031
\begin{verbatim}
3132
>>> import pdb
3233
>>> import mymodule
3334
>>> pdb.run('mymodule.test()')
34-
(Pdb)
35+
> <string>(0)?()
36+
(Pdb) continue
37+
> <string>(1)?()
38+
(Pdb) continue
39+
NameError: 'spam'
40+
> <string>(1)?()
41+
(Pdb)
3542
\end{verbatim}
3643

3744
Typical usage to inspect a crashed program is:
@@ -40,13 +47,19 @@ \chapter{The Python Debugger}
4047
>>> import pdb
4148
>>> import mymodule
4249
>>> mymodule.test()
43-
(crashes with a stack trace)
50+
Traceback (innermost last):
51+
File "<stdin>", line 1, in ?
52+
File "./mymodule.py", line 4, in test
53+
test2()
54+
File "./mymodule.py", line 3, in test2
55+
print spam
56+
NameError: spam
4457
>>> pdb.pm()
45-
(Pdb)
58+
> ./mymodule.py(3)test2()
59+
-> print spam
60+
(Pdb)
4661
\end{verbatim}
4762

48-
The debugger's prompt is ``\code{(Pdb) }''.
49-
5063
The module defines the following functions; each enters the debugger
5164
in a slightly different way:
5265

@@ -111,7 +124,8 @@ \section{Debugger Commands}
111124
statements and are executed in the context of the program being
112125
debugged. Python statements can also be prefixed with an exclamation
113126
point (``\code{!}''). This is a powerful way to inspect the program
114-
being debugged; it is even possible to change variables. When an
127+
being debugged; it is even possible to change a variable or call a
128+
function. When an
115129
exception occurs in such a statement, the exception name is printed
116130
but the debugger's state is not changed.
117131

0 commit comments

Comments
 (0)