Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
210bd208
Commit
210bd208
authored
Nov 05, 2002
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement a `pp' command, which is like `p' except that it
pretty-prints the value of its expression argument.
parent
c2f7757e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
Lib/pdb.py
Lib/pdb.py
+21
-6
No files found.
Lib/pdb.py
View file @
210bd208
...
...
@@ -11,6 +11,7 @@ import bdb
from
repr
import
Repr
import
os
import
re
import
pprint
# Create a custom safe Repr instance and increase its maxstring.
# The default of 30 truncates error messages too easily.
...
...
@@ -532,19 +533,29 @@ class Pdb(bdb.Bdb, cmd.Cmd):
print
'*** Not yet returned!'
do_rv
=
do_retval
def
do_p
(
self
,
arg
):
def
_getval
(
self
,
arg
):
try
:
value
=
eval
(
arg
,
self
.
curframe
.
f_globals
,
return
eval
(
arg
,
self
.
curframe
.
f_globals
,
self
.
curframe
.
f_locals
)
except
:
t
,
v
=
sys
.
exc_info
()[:
2
]
if
type
(
t
)
==
type
(
''
):
if
isinstance
(
t
,
str
):
exc_type_name
=
t
else
:
exc_type_name
=
t
.
__name__
print
'***'
,
exc_type_name
+
':'
,
`v`
r
eturn
r
aise
print
`value`
def
do_p
(
self
,
arg
):
try
:
print
repr
(
self
.
_getval
(
arg
))
except
:
pass
def
do_pp
(
self
,
arg
):
try
:
pprint
.
pprint
(
self
.
_getval
(
arg
))
except
:
pass
def
do_list
(
self
,
arg
):
self
.
lastcmd
=
'list'
...
...
@@ -817,6 +828,10 @@ Print the arguments of the current function."""
print
"""p expression
Print the value of the expression."""
def
help_pp
(
self
):
print
"""pp expression
Pretty-print the value of the expression."""
def
help_exec
(
self
):
print
"""(!) statement
Execute the (one-line) statement in the context of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment