CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Wed, 16 Jul 2025 19:41:14 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20081007194400
location: https://web.archive.org/web/20081007194400/https://wiki.python.org/moin/PdbRcIdea
server-timing: captures_list;dur=0.821920, exclusion.robots;dur=0.027707, exclusion.robots.policy;dur=0.012560, esindex;dur=0.015827, cdx.remote;dur=32.618530, LoadShardBlock;dur=827.182656, PetaboxLoader3.datanode;dur=361.428643, PetaboxLoader3.resolve;dur=320.388691
x-app-server: wwwb-app213
x-ts: 302
x-tr: 896
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app213; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Wed, 16 Jul 2025 19:41:16 GMT
content-type: text/html;charset=utf-8
x-archive-orig-date: Wed, 08 Oct 2008 02:44:00 GMT
x-archive-orig-server: Apache/2.2.3 (Debian) mod_fastcgi/2.4.2
x-archive-orig-pragma: no-cache
x-archive-orig-cache-control: no-cache
x-archive-orig-expires: -1
x-archive-orig-vary: Accept-Language,Cookie,User-Agent
x-archive-orig-connection: close
x-archive-orig-transfer-encoding: chunked
x-archive-orig-x_commoncrawl_parsesegmentid: 4339
x-archive-orig-x_commoncrawl_originalurl: https://wiki.python.org/moin/PdbRcIdea
x-archive-orig-x_commoncrawl_urlfp: -3225493225477721567
x-archive-orig-x_commoncrawl_hostfp: -6088210169746486586
x-archive-orig-x_commoncrawl_signature: 6d3df2799dad98aa001ae3061b3b31cd
x-archive-orig-x_commoncrawl_crawlno: 1
x-archive-orig-x_commoncrawl_fetchtimestamp: 1223433840906
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Tue, 07 Oct 2008 19:44:00 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Sun, 30 Apr 2006 05:18:28 GMT", ; rel="prev memento"; datetime="Tue, 23 Oct 2007 00:19:44 GMT", ; rel="memento"; datetime="Tue, 07 Oct 2008 19:44:00 GMT", ; rel="next memento"; datetime="Sun, 02 May 2010 01:22:29 GMT", ; rel="last memento"; datetime="Mon, 28 Apr 2025 18:52:05 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 1224045492897_37-c/1224045528072_5.arc.gz
server-timing: captures_list;dur=0.495525, exclusion.robots;dur=0.018945, exclusion.robots.policy;dur=0.009960, esindex;dur=0.010537, cdx.remote;dur=8.231971, LoadShardBlock;dur=814.695504, PetaboxLoader3.resolve;dur=1745.939266, PetaboxLoader3.datanode;dur=187.064374, load_resource;dur=1319.296168
x-app-server: wwwb-app213
x-ts: 200
x-tr: 2187
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
PdbRcIdea - PythonInfo Wiki
Problem
You'd like to include Python scripts into my .pdbrc, but only pdb commands are allowed there.
Solution
Use execfile() to run a file containing your Python code.
.pdbrc may look like this:
# .pdbrc only allows for debugger commands; you cannot insert Python # scripts. # To overcome this restriction, this .pdbrc executes ~/.pdbrc.py, # which can contain arbitrary Python commands (including a call to a # local pdbrc.py (no leading dot!) in your working directory if it # exists). # If ~/.pdbrc.py is missing, you get an error message (which doesn't # hurt). execfile(os.path.expanduser("~/.pdbrc.py"))
and this is an example ~/.pdbrc.py:
print ".pdbrc.py started" # Command line history: import readline histfile = ".pdb-pyhist" try: readline.read_history_file(histfile) except IOError: pass import atexit atexit.register(readline.write_history_file, histfile) del histfile readline.set_history_length(200) # return to debugger after fatal exception (Python cookbook 14.5): def info(type, value, tb): if hasattr(sys, 'ps1') or not sys.stderr.isatty(): sys.__excepthook__(type, value, tb) import traceback, pdb traceback.print_exception(type, value, tb) print pdb.pm() sys.excepthook = info # From (on my machine) /usr/local/lib/python2.3/less user.py: import os home = os.curdir # Default if 'HOME' in os.environ: home = os.environ['HOME'] elif os.name == 'posix': home = os.path.expanduser("~/") elif os.name == 'nt': # Contributed by Jeff Bauer if 'HOMEPATH' in os.environ: if 'HOMEDRIVE' in os.environ: home = os.environ['HOMEDRIVE'] + os.environ['HOMEPATH'] else: home = os.environ['HOMEPATH'] # Make sure home always ends with a directory separator: home = os.path.realpath(home) + os.sep # Try to execute local file (if any) unless we are in the home dir. if home != os.path.realpath(os.curdir) + os.sep: # Avoid recursively loading this file. try: _already_loaded += 1 except NameError: _already_loaded = 1 if _already_loaded < 3: try: execfile("pdbrc.py") except IOError: pass # Cleanup any variables that could otherwise clutter up the namespace. try: del atexit del home del info del os del pdb del readline del rlcompleter # careful here: del _already_loaded except NameError: # Probably this is a second pdbrc that has been loaded. pass print ".pdbrc.py finished"
EditText (last edited 2006-10-17 23:04:27 by mauritsvanrees)