P
pythonic
Hi,
I use '_' for localization in my program. The problem is when testing
the program using python intractive mode I lose _ function.
One solution is put following in PYTHONSTARTUP file.
--
import readline
def __enforce_underscore__ (): __builtins__._ = str
readline.set_pre_input_hook (__enforce_underscore__)
--
My program in startup imports a module which customize the env.
Putting above in that module doesn't solve the problem. Any
cleaner/better way?
Honestly, I was expecting once overriden _ in builtins it would be honored.
This how I reproduce the problem.
Python 2.3.3 (#1, May 7 2004, 10:31:40)
File "<stdin>", line 1, in ?
TypeError: 'str' object is not callable
TIA.
I use '_' for localization in my program. The problem is when testing
the program using python intractive mode I lose _ function.
One solution is put following in PYTHONSTARTUP file.
--
import readline
def __enforce_underscore__ (): __builtins__._ = str
readline.set_pre_input_hook (__enforce_underscore__)
--
My program in startup imports a module which customize the env.
Putting above in that module doesn't solve the problem. Any
cleaner/better way?
Honestly, I was expecting once overriden _ in builtins it would be honored.
This how I reproduce the problem.
Python 2.3.3 (#1, May 7 2004, 10:31:40)
Traceback (most recent call last):def localizer(s): return str(s)
__builtins__.__dict__['_'] = localizer
__('some text') 'some text'
_ 'some text'
_('some text')
File "<stdin>", line 1, in ?
TypeError: 'str' object is not callable
TIA.