How to use _ in interactive mode

2005-11-25 Thread 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)
>>> def localizer(s): return str(s)
>>> __builtins__.__dict__['_'] = localizer
>>> _

>>> _('some text')
'some text'
>>> _
'some text'
>>> _('some text')
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: 'str' object is not callable

TIA.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python for embedded linux?

2005-08-02 Thread pythonic
Where can I find a minimal version of python (less than 2 MB) suitable for
a web server on an embedded linux system?  The small size is required
because the system lives on flash memory.

Thanks,
Ken Seehart




-- 
http://mail.python.org/mailman/listinfo/python-list