Skip to content

Instantly share code, notes, and snippets.

import psyco
psyco.full()
def foo(arg):
"""triggers a breakpoint"""
i, j, k = [arg]*3
1/0
return arg*2
if __name__ == '__main__':
$ pdb hello_pdb.py
> /home/sevas/code/python/hello_pdb.py(1)()
-> import psyco
(Pdb) c
Traceback (most recent call last):
File "/usr/bin/pdb", line 1213, in main
pdb._runscript(mainpyfile)
File "/usr/bin/pdb", line 1138, in _runscript
self.run(statement, globals=globals_, locals=locals_)
File "/usr/lib/python2.5/bdb.py", line 366, in run
"""
Psyco stub: should implement all the external API from psyco.
Taken from the pydev eclipse extension.
"""
def proxy(func, *args, **kwargs):
return func
def bind(func, *args, **kwargs):
return func
@sevas
sevas / dotpdbrc
Created September 11, 2010 13:16
#.pdbrc
import sys
import os
sys.path += [os.getenv("HOME")]
import pdb_psyco_stub
sys.modules['psyco'] = pdb_psyco_stub
print '*** Info : Psyco module replaced with pdb_psyco_stub'
from pprint import pprint
$ pdb hello_pdb.py
*** Info : Psyco module replaced with pdb_psyco_stub
> /home/sevas/code/python/hello_pdb.py(1)()
-> import psyco
(Pdb) c
Traceback (most recent call last):
...snip...
File "hello_pdb.py", line 7, in foo
1/0
ZeroDivisionError: integer division or modulo by zero
@ECHO off
ECHO Setting environment for EPD 6.2.2 (Python 2.6)
@SET PYTHON_ROOT=c:\Python26_EPD622
@SET PYTHON_INCLUDE=%PYTHON_ROOT%\include
@SET PYTHON_LIB=%PYTHON_ROOT%\python26.lib
@SET PATH=%PYTHON_ROOT%;%PYTHON_ROOT%\Scripts;%PYTHON_ROOT%\Lib;%PATH%
REM Optionnal, uncomment if you want to use a specific startup file
REM @SET PYTHONSTARTUP=%APPDATA%\pythonrc.py
export OLD_PATH=$PATH
# switching functions
select_epd62()
{
echo "Setting environment for EPD 6.2 (Python 2.6)"
PATH="/Library/Frameworks/Python.framework/Versions/6.2/bin:${OLD_PATH}"
export PATH
}
from __future__ import division
import numpy as np
from scipy.weave import inline, converters
def load_data(filename):
zbuf = np.fromfile(filename, dtype=np.float32, count=128*128*4)
zbuf.shape = (128,128)
return zbuf
[Sat Apr 23 11:39:26 2011] [notice] caught SIGTERM, shutting down
[Sat Apr 23 11:39:44 2011] [error] python_init: Python version mismatch, expected '2.6.5', found '2.6.6'.
[Sat Apr 23 11:39:44 2011] [error] python_init: Python executable found '/usr/bin/python'.
[Sat Apr 23 11:39:44 2011] [error] python_init: Python path being used '/usr/lib/python2.6/:/usr/lib/python2.6/plat-linux2:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-dynload'.
[Sat Apr 23 11:39:44 2011] [notice] mod_python: Creating 8 session mutexes based on 6 max processes and 25 max threads.
[Sat Apr 23 11:39:44 2011] [notice] mod_python: using mutex_directory /tmp
[Sat Apr 23 11:39:44 2011] [warn] mod_wsgi: Compiled for Python/2.6.5.
[Sat Apr 23 11:39:44 2011] [warn] mod_wsgi: Runtime using Python/2.6.6.
[Sat Apr 23 11:39:44 2011] [notice] Apache/2.2.16 (Ubuntu) mod_python/3.3.1 Python/2.6.6 mod_wsgi/3.2 configured -- resuming normal operations
@sevas
sevas / gist:1021380
Created June 12, 2011 09:35
python switcher bash funcs
export OLD_PATH=$PATH
select_system_python26()
{
echo "Setting environment for System Python 2.6"
PATH="/System/Library/Frameworks/Python.framework/Versions/2.6/bin/:${OLD_PATH}"
export PATH
}