-
Notifications
You must be signed in to change notification settings - Fork 1
/
pdbrc
42 lines (32 loc) · 1.35 KB
/
pdbrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Enable tab completion
import pdb
import rlcompleter
pdb.Pdb.complete = rlcompleter.Completer(locals()).complete
# Sometimes when you do something funky, you may lose your terminal echo. This
# should restore it when spanwning new pdb.
import termios, sys
termios_fd = sys.stdin.fileno()
termios_echo = termios.tcgetattr(termios_fd)
termios_echo[3] = termios_echo[3] | termios.ECHO
termios_result = termios.tcsetattr(termios_fd, termios.TCSADRAIN, termios_echo)
# For ordinary Python objects, ppo will pretty-print members and their values.
alias po pp %1.__dict__
# ppio runs ppo over a sequence of objects
alias ppo po [a.__dict__ for a in %*]
# Print a dictionary, sorted. %1 is the dict, %2 is the prefix for the names.
# alias p_ for k in sorted(%1.keys()): print("%s%-15s= %-80.80s" % ("%2", k, repr(%1[k])))
alias p_ for k in sorted(%1): print("%s = %-80.80s" % (k, repr(%1[k])))
# Print the member variables of a thing.
# alias pi p_ %1.__dict__ %1.
alias pi p_ %1.__dict__
# Print instance variables in self
alias ps pi self
# Print the locals.
alias pl p_ locals()
# Next and list, and step and list.
alias nl n;;l
alias sl s;;l
# 'inspect x' will print the source code for a method, class or function.
alias inspect import inspect; print(inspect.getsource(%1))
# 'help x' opens the man-style help viewer from the interpreter on an object
alias hh !print(help(%1))