[Python-ideas] Binary f-strings

Steven D'Aprano steve at pearwood.info
Mon Sep 28 05:28:45 CEST 2015


On Mon, Sep 28, 2015 at 01:03:32PM +1000, Chris Angelico wrote:
[...]
> >>> восток = 1961
> >>> apollo = 1969
> >>> print(f"It took {apollo-восток} years to get from orbit to the moon.")
> It took 8 years to get from orbit to the moon.
> >>> print(b"It took {apollo-восток} years to get from orbit to the moon.")
>   File "<stdin>", line 1
> SyntaxError: bytes can only contain ASCII literal characters.
> 
> If that were a binary f-string, those Cyrillic characters should still
> be legal (as they define an identifier, rather than ending up in the
> code). Would it confuse (a) humans, or (b) tools, to have these "texty
> bits" inside a byte string?

It would confuse the heck out of me. I leave it to the reader to decide 
whether I am a human or a tool.


-- 
Steve


More information about the Python-ideas mailing list