On Fri, Sep 18, 2020 at 09:05:39AM +1000, Chris Angelico wrote:

> > f-strings are not literals. They are a form of eval().
> 
> Oh, that makes 'em sound way too scary :) They're more akin to a list
> display - a syntactic structure that yields a well-defined object, and
> has expressions inside it.

*shrug*

Okay, but either way they certainly aren't a literal. Anyone who doubts 
that ought to disassemble an f-string and see for themselves:

    import dis
    code = compile("f'{x+1} {x-1}'", '', 'eval')
    dis.dis(code)


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/N7ENCWDZBJNYUI7FO627FW5L6MVHWGTW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to