A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-June/025827.html below:

PEP 292, Simpler String Substitutions

[Python-Dev] Re: PEP 292, Simpler String SubstitutionsBarry A. Warsaw barry@zope.com
Sat, 22 Jun 2002 20:56:57 -0400
>>>>> "CT" == Christian Tismer <tismer@tismer.com> writes:

    CT> By no means.  allvars() is something like locals() or
    CT> globals(), just an explicit way to produce a dictionary of
    CT> variables.

I'd be ok with something like allvars() and requiring a dictionary to
the .sub() method, /if/ allvars() were a method on a frame object.  I
really, really do want to write in my i18n programs:

    def whereBorn(name):
	country = countryOfOrigin(name)
	return _('$name was born in $country')

I'd be fine if the definition of _() could reach into the frame of
whereBorn() and give me a list of all variables, including ones in
nested scopes.  Actually, that'd be a lot better than what I do now
(although truth be told, losing access to nested scoped variables is
only a hypothetical limitation in the code I've written).

The feature would be useless to me if I had to pass some explicit
dictionary into the _() method.  It makes writing i18n code extremely
tedious.  Invariably, the unsafeness of an implicit dictionary happens
when strings come from untrusted sources, and your .py file can't be
considered untrusted.  In those cases, creating an explicit dictionary
for interpolation is fine, but they also tend not to overlap with i18n
much.

-Barry




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4