[IPython-user] ipython, debug, gettext and underscore

Stefan van der Walt stefan@sun.ac...
Wed Aug 8 19:36:02 CDT 2007

On Wed, Aug 08, 2007 at 11:52:07AM +0300, dima Q wrote:
> Hi I was wondering if anyone figured out how to use ipython's debug features
> with gettext safely.
> gettext.install() registers _ (underscore) in builtins, so that you can do
> print _("text to translate"),
> however ipython uses _ for last return value (which works, because it's local
> to ipython apparently)
> on the other hand when one runs debug from ipython and any command that returns
> any program data,
> debug manages to set _ for the entire program, after which every single _
> ("...") in the program dies
> with TypeError: <xxx> not callable.
> Is there a way to disable usage of single underscore in ipython and debug?
> I don't mind all the other __, ___, _i, _iii, _1, _2 and whatnot, just a single
> underscore...

This seems to be a pdb issue.  Under IPython, the use of the '_'
variables can be disabled by placing

ip.ex("import __builtin__")
ip.ex("__builtin__._ = True")

in your ~/.ipython/ipy_user_conf.py.

One workaround for your problem is to install pydb, which doesn't
store the last result in '_'.


More information about the IPython-user mailing list