Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > gettext and the interpreter

Reply
Thread Tools

gettext and the interpreter

 
 
Hans-Joachim Widmaier
Guest
Posts: n/a
 
      04-03-2004
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
 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      04-03-2004
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

 
Reply With Quote
 
 
 
 
Hans-Joachim Widmaier
Guest
Posts: n/a
 
      04-08-2004
Am Sat, 03 Apr 2004 23:22:47 +0200 schrieb Peter Otten:

> Try redefining sys.displayhook, e. g.:


Thanks a lot! This is the stuff I keep having problems with finding in the
docs.

[Sorry for answering late, but Google gave me only empty pages, and I'm
just now able to do it properly.]

Hans-Joachim
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python embedded interpreter: how to initialize the interpreter ? ycollet@freesurf.fr Python 3 01-03-2007 01:00 AM
Encoding problems with gettext and wxPython: how to do things in "good style" =?iso-8859-1?B?QW5kcuk=?= Python 0 03-02-2006 01:09 AM
gettext and "disambiguating comments" Terry Hancock Python 1 07-11-2005 10:40 PM
[ANT] apply-task and relative attribute (gettext-like internationalisation/localisation) Daniel Leidert Java 0 05-28-2005 10:44 AM
gettext support for Linux and Windows Daniele Python 2 10-14-2004 10:06 PM



Advertisments