Permalink
Browse files

Merge pull request #19 from dimasad/master

Inclusion of run, runeval and runcall so the api of ipdb is equal to the original pdb
  • Loading branch information...
2 parents dc72c95 + 1bef208 commit b42394ba2a7611b6134dfbc9b9ed308a362b2121 @gotcha committed Mar 18, 2012
Showing with 32 additions and 10 deletions.
  1. +2 −0 HISTORY.txt
  2. +14 −9 README.rst
  3. +4 −1 ipdb/__init__.py
  4. +12 −0 ipdb/__main__.py
View
@@ -6,6 +6,8 @@ Changelog
- Python 3 support.
[Piet Delport]
+- Added the functions ``runcall``, ``runeval`` and ``run``.
+ [dimasad]
0.6.1 (2011-10-17)
View
@@ -1,20 +1,25 @@
IPython `pdb`
=============
-Use
+Use
+---
-::
-
- from ipdb import set_trace; set_trace()
-
-or
+ipdb exports functions to access the IPython_ debugger, which features
+tab completion, syntax highlighting, better tracebacks, better introspection
+with the same interface as the `pdb` module.
+Example usage:
::
- from ipdb import pm; pm()
+ import ipdb
+ ipdb.set_trace()
+ ipdb.pm()
+ ipdb.run('x[0] = 3')
+ result = ipdb.runcall(function, arg0, arg1, kwarg='foo')
+ result = ipdb.runeval('f(1,2) - 3')
-You then get all IPython_ features (tab completion, syntax highlighting, better
-tracebacks, better introspection) right in `pdb`.
+The post-mortem function, ``ipdb.pm()``, is equivalent to the magic function
+``%debug``.
.. _IPython: http://ipython.org
View
@@ -1,5 +1,8 @@
-from ipdb.__main__ import set_trace, post_mortem, pm
+from ipdb.__main__ import set_trace, post_mortem, pm, run, runcall, runeval
pm # please pyflakes
post_mortem # please pyflakes
+run # please pyflakes
+runcall # please pyflakes
+runeval # please pyflakes
set_trace # please pyflakes
View
@@ -70,6 +70,18 @@ def pm():
post_mortem(sys.last_traceback)
+def run(statement, globals=None, locals=None):
+ Pdb(def_colors).run(statement, globals, locals)
+
+
+def runcall(*args, **kwargs):
+ return Pdb(def_colors).runcall(*args, **kwargs)
+
+
+def runeval(expression, globals=None, locals=None):
+ return Pdb(def_colors).runeval(expression, globals, locals)
+
+
def main():
if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):
print "usage: ipdb.py scriptfile [arg] ..."

0 comments on commit b42394b

Please sign in to comment.