I've been opening source files by hand in TextMate and it's annoyingly tedious so I wrote a quick helper this morning and added it to __builtins__ via sitecustomize so I wouldn't have to mess around anymore.
def mate(obj):
import os, inspect, logging
try:
fn = inspect.getsourcefile(obj)
_, line = inspect.getsourcelines(obj)
os.system("/usr/local/bin/mate -d -a -l %d %s" % (line, fn))
except IOError, e:
logging.exception(e)
Now in the interpreter:
>>> import logging
>>> mate(logging.error)
will launch TextMate and put the caret at the appropriate line number. If obj has no source then an exception is logged and no source is displayed.