[Python-ideas] String interpolation for all literal strings

Eric V. Smith eric at trueblade.com
Thu Aug 6 15:43:39 CEST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/06/2015 04:27 AM, Eric V. Smith wrote:
>> Agreed that raw strings probably shouldn't be scanned.  Since it 
>> may happen that some surprising behavior occurs (long after it's 
>> past __future__), there should be some way to prevent scanning.
>> To me that either means r'' strings don't get scanned or f'' is 
>> required.
> 
> I've come around to raw strings not being scanned.

One advantage of the f-string approach is that you could interpolate
raw strings if you wanted to:

>>> x=42

>>> f"\b {x}"
'\x08 42'

>>> rf"\b {x}"
'\\b 42'

Eric.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)

iQEcBAEBAgAGBQJVw2SLAAoJENxauZFcKtNx0hEIAKZg9urj8lLI11EDLcnNrcQN
6wFmILA6t4FxIRw9CHAJxvE02rrQhVgj/KzknSbMAilvb9PHI7Q7RTJ/yS0xbCc4
Mw+0nLCJMG/S3R7vrVyjroCO97FBlMCCyrZXGZlVh6/WFR4UnVFhqEIUO5i/kVbL
4fNc57wVY5ibfsu1NXkn0YmZqKEb6+t434wmb89bta5mYztG845CK+Vge+dT1zoi
hIO05Vy9D+eUbWrVl+9sQAoZmZboemGyugRzKv6uZpTis5dyCeFxAWm4GQNtQe/G
3ICwUBTRKzvldkd5oc8ehi3bnGHUCTn8R4j4lPneO/S8pMn6vWsvkfFENHHSE/8=
=gUZ0
-----END PGP SIGNATURE-----


More information about the Python-ideas mailing list