Marking translatable strings

Tim Peters tim_one at email.msn.com
Sun Sep 19 18:58:50 EDT 1999


[Tim]
> I agree with everyone else <wink> that the special meaning of "_" in
> interactive mode is unlikely to create a problem for you.

[Skip Montanaro]
> Am I the only person who occasionally pastes code from a Python file I'm
> editing into an interactive session to try it out in isolation?

Yes -- or at least the only one who pastes in code fragments without also
pasting in the functions they call.

D:\Python>python
Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 1 + 3
4
>>> _
4
>>> def _(): print "hi!"
...
>>> 1 + 3
4
>>> _()
hi!
>>> __builtins__._
4
>>>

That is, the definition of "_" gets installed in the global (== local, here)
namespace, shadowing the "_" in the builtin namespace.  The eval loop
overwrites the builtin "_" specifically (it doesn't follow the normal
scoping rules).  So the pasted code will work fine; you'll simply have a
hard time getting at the builtin interactive "_" shortcut.

i-tell-you-that-guido-thought-of-everything<wink>-ly y'rs  - tim






More information about the Python-list mailing list