[Python-ideas] Binary f-strings

Chris Angelico rosuav at gmail.com
Sat Oct 3 05:33:12 CEST 2015


On Sat, Oct 3, 2015 at 1:27 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Fri, Oct 02, 2015 at 09:00:56AM -0700, Guido van Rossum wrote:
>> Bingo. IMO the exact same arguments that show why f'{x} {y}' is better than
>> '%s %s' % (x, y) applies to byte strings. It would be totally acceptable if
>> it only took bytes (and bytearray, and memoryview) and numbers (which we
>> can guarantee are rendered in ASCII only).
>
> As Chris A pointed out earlier, identifiers are not ASCII only. What are
> we to make of something like this?
>
>     bf'{αριθμός + 1}'
>
> And don't say "re-write your code to only use ASCII variable names" :-)

It should be technically legal, btw; it's just going to look very odd.
The check for ASCII-only has to be done _after_ the fracturing into
strings and expressions. But I don't like how that reads.

ChrisA


More information about the Python-ideas mailing list