By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,534 Members | 1,322 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,534 IT Pros & Developers. It's quick & easy.

gettext and the interpreter

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.