Problem with mixing doctest with gettext _()
Pierre Rouleau
prouleau at impathnetworks.com
Fri Feb 27 11:20:06 EST 2004
Skip Montanaro wrote:
>
> If you really want a dummy _() you can also stuff your version into
> builtins:
>
> >>> import __builtin__
> >>> def foo(s): return s
> ...
> >>> __builtin__._ = foo
> >>> _
> <function foo at 0x1d6670>
> >>> _("hi")
> 'hi'
>
I tried that, but it only works for the first call...
[Shell buffer started: python.exe]
Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import __builtin__
>>> def foo(s): return s
...
>>> __builtin__._ = foo
>>> _
<function foo at 0x008F98B0>
>>> _
<function foo at 0x008F98B0>
>>> _('hi')
'hi'
>>> _
'hi'
>>> _('Hello')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'str' object is not callable
>>>
Pierre
More information about the Python-list
mailing list