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/2006-May/064934.html below:

[Python-Dev] PEP 3101 Update

[Python-Dev] PEP 3101 Update [Python-Dev] PEP 3101 UpdateSteven Bethard steven.bethard at gmail.com
Mon May 8 03:14:59 CEST 2006
On 5/7/06, Edward Loper <edloper at gradient.cis.upenn.edu> wrote:
> Talin wrote:
> >      Braces can be escaped using a backslash:
> >
> >          "My name is {0} :-\{\}".format('Fred')
> >
> >      Which would produce:
> >
> >          "My name is Fred :-{}"
>
> Do backslashes also need to be backslashed then?  If not, then what is
> the translation of this:?
>
>      r'abc\{%s\}' % 'x'

I believe the proposal is taking advantage of the fact that '\{' is
not interpreted as an escape sequence -- it is interpreted as a
literal backslash followed by an open brace:

>>> '\{'
'\\{'
>>> '\\{'
'\\{'
>>> r'\{'
'\\{'

Thus, for 'abc\{0\}'.format('x'), you should get an error because
there are no replacement fields in the format string.

STeVe
--
Grammar am for people who can't think for myself.
        --- Bucky Katt, Get Fuzzy
More information about the Python-Dev mailing list

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