[Python-Dev] Replacement for print in Python 3.0
solipsis at pitrou.net
Thu Sep 8 13:48:01 CEST 2005
Le jeudi 08 septembre 2005 à 19:12 +0900, Stephen J. Turnbull a écrit :
> It would be
> nice to be able to lose the "_()" calls to gettext(). The function
> would look to see if a message catalog was available for the current
> output stream, and if not, do no translation.
That doesn't sound right to me.
1. You still need to do automatic extraction of these strings (gettext
has tools for that, which rely on the use of the "_()" function - or any
other dedicated function (*)).
2. You can't assume that all strings must be i18n'ed. For example if I'm
interfacing with the user via a text-based network protocol which has a
field named "Length", I don't want that "Length" field to be replaced
with the Japanese translation of the word "Length".
For i18n, "explicit is better than implicit" ;) The beauty of "_()" is
that it's at the same time explicit, easily recognizable, and very short
to type and read (it doesn't clutter the source code). If I dare say,
the "%" operator has the same qualities.
(*) of course more automatization of what gettext does could be a nice
> But so far, I don't see
> any reason why your proposal for the $1 positional syntax in printf()
> hinders any of the above.
As I said Python needs an operator or function that does string
formatting using a simple template, *without* doing output at the same
time. The current syntax is the '%' operator, it could change, but it
shouldn't be removed in favor of an inflexible print-with-formatting
More information about the Python-Dev