~ipython-dev/ipython/set_trace

« back to all changes in this revision

Viewing changes to IPython/__init__.py

  • Committer: Ondrej Certik
  • Date: 2009-07-16 20:49:39 UTC
  • Revision ID: ondrej@certik.cz-20090716204939-fywmmlidk482sj25
set_trace() moved from __init__.py to ipapi.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
 
60
60
import Shell
61
61
 
62
 
def set_trace():
63
 
    """
64
 
    Starts the IPython shell inplace.
65
 
 
66
 
    Example:
67
 
 
68
 
    >> import IPython
69
 
    >> IPython.set_trace()
70
 
 
71
 
    The user namespace is set to the union of globals() and locals(), e.g.
72
 
    calling set_trace() is exactly equivalent to:
73
 
 
74
 
        import IPython
75
 
        IPython.Shell.IPShell(user_ns=dict(globals(), **locals())).mainloop()
76
 
 
77
 
    but the actual implementation of set_trace() needs to use the inspect
78
 
    module, because it needs to access the parents frame.
79
 
 
80
 
    """
81
 
    import inspect
82
 
    frame = inspect.currentframe().f_back
83
 
    globals = frame.f_globals
84
 
    locals = frame.f_locals
85
 
    Shell.IPShell(user_ns=dict(globals, **locals)).mainloop()
86
 
 
87
62
# Release data
88
63
from IPython import Release # do it explicitly so pydoc can see it - pydoc bug
89
64
__author__   = '%s <%s>\n%s <%s>\n%s <%s>' % \