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

[Python-Dev] PEP_215_ (string interpolation) alternative EvalDict

[Python-Dev] PEP_215_ (string interpolation) alternative EvalDict [Python-Dev] PEP_215_ (string interpolation) alternative EvalDictJason Orendorff jason@jorendorff.com
Mon, 14 Jan 2002 22:16:11 -0600
> On Mon, 14 Jan 2002, Skip Montanaro wrote:
> >     $'BDFL = $sys.copyright.split()[4].upper()'
> >     ---> ('BDFL = ' + str(sys.copyright.split()[4].upper()))
> >
> > How to you know when to stop gobbling after seeing a dollar sign in the
> > string?
> 
> Parse using the "NAME trailer*" production in Grammar/Grammar.

Except that whitespace is significant, at least in the sample
implementation:

>>> i = Itpl.itpl
>>> x=4
>>> y=3
>>> i("This is x: $x.  This is y: $y.")  # doesn't grab (x.This)
'This is x: 4.  This is y: 3.'
>>> i("This is x: $x.This is y: $y.")    # does grab (x.This)
AttributeError: 'int' object has no attribute 'This'

This doesn't seem to be mentioned in the PEP.

## Jason Orendorff    http://www.jorendorff.com/



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