469,352 Members | 1,754 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

gettext and the interpreter

Recently I wanted to do some debugging using one module of my first
Python program using the gettext module. I just didn't find a way to
disable the interpreter binding the last result to _, which ought to
be (and stay) a function.

Anybody got an idea how to do it?

Hans-Joachim
Jul 18 '05 #1
1 1217
Hans-Joachim Widmaier wrote:
Recently I wanted to do some debugging using one module of my first
Python program using the gettext module. I just didn't find a way to
disable the interpreter binding the last result to _, which ought to
be (and stay) a function.

Anybody got an idea how to do it?


Try redefining sys.displayhook, e. g.:
import sys, __builtin__
def myhook(value): .... if value is not None:
.... __builtin__.__last__ = value
.... sys.stdout.write("%r\n" % value)
.... sys.displayhook = myhook
Now the last non-None value will be stored in __last__ instead of _:
1 1 _ Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name '_' is not defined __last__

1

Peter

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Daniel CAUSSE | last post: by
1 post views Thread by Dave Patton | last post: by
14 posts views Thread by Pierre Rouleau | last post: by
1 post views Thread by Terry Hancock | last post: by
13 posts views Thread by cantabile | last post: by
1 post views Thread by James T. Dennis | last post: by
6 posts views Thread by =?iso-8859-1?B?QW5kcuk=?= | last post: by
2 posts views Thread by paolob | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.