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/025587.html below:

[Python-Dev] PEP 292, Simpler String Substitutions

[Python-Dev] PEP 292, Simpler String SubstitutionsBarry A. Warsaw barry@zope.com
Wed, 19 Jun 2002 08:29:39 -0400
>>>>> "DB" == Duncan Booth <duncan@rcp.co.uk> writes:

    DB> What I really don't understand is why there is such pressure
    DB> to get an alternative interpolation added as methods to str &
    DB> unicode rather than just adding an interpolation module to the
    DB> library?  e.g.

Because I don't think there's all that much useful variation, open
issues in this PEP notwithstanding.  A module seems pretty heavy for
such a simple addition.  It might obviate the need for a PEP
though. :)

    | from interpolation import sub
    | def birth(self, name):
    |     country = self.countryOfOrigin['name']
    |     return sub('${name} was born in ${country}', vars())

    DB> I added in the explicit vars() parameter because the idea of a
    DB> possibly unknown template string picking up arbitrary
    DB> variables is, IMHO, a BAD idea.

Only if the template string comes from an untrusted source.  If it's
in your code, there should be no problem, and if there is, it's a
programming bug.

vars() doesn't cut it as mentioned in a previous reply.

-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