Tuesday, May 31, 2016

print more source code in the IPython debugger

This hardly deserves its own post, but I was doing some IPython debugging and wanted to see a little bit more source code than the few lines of context that it showed me by default. It turns out you can type "list" at the debugger prompt to see more.

In [7]: %debug
> /Users/tsrice/anaconda2/lib/python2.7/site-packages/astropy/io/fits/connect.py(224)write_table_fits()
222 os.remove(output)
223 else:
--> 224 raise IOError("File exists: {0}".format(output))
225
226 # Create a new HDU object
ipdb> list
219 # Check if output file already exists
220 if isinstance(output, string_types) and os.path.exists(output):
221 if overwrite:
222 os.remove(output)
223 else:
--> 224 raise IOError("File exists: {0}".format(output))
225
226 # Create a new HDU object
227 if input.masked:
228 #float column's default mask value needs to be Nan
229 for column in six.itervalues(input.columns):
view raw thing.py hosted with ❤ by GitHub

No comments:

Post a Comment