syntax questions

François Pinard pinard at iro.umontreal.ca
Wed Jul 24 16:27:49 EDT 2002


[Fredrik Lundh]

> for some reason, people doing internationalization (i18n) and localization
> (l10n) stuff seem to prefer to use functions called "_", probably only
> to confuse people like you and me.

The habit came into Python from C, and it came into C from me! :-)

In C, `_()' is implemented as a C pre-processor macro, as a short form for
the `gettext()' macro which, we soon discovered, was visually obtrusive.
Marking strings for localisation should consume as little horizontal space
as possible, and not be too distracting for people reading source code,
while not conflicting with other usages.  For example, using a single
letter would surely have been source for a lot of conflicts! :-)

In C, `_' had no previous meaning.  To check it, I implemented `_()' in a
few widely ported packages (the `tar' program among others), and since no
user complained for a few releases, we took this as a kind of proof that
it was safe to use more generally, and the habit sprout from there.

I'm not sure `_' is ideal in Python, even if not bad.  `_' in Python has
already the meaning, in interactive mode, of the last computation.  Moreover,
by fully being a run-time function, it is a bit late to get help from the
Python compiler, if more sophisticated usages ever asks for such help.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list