Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why no from __future__ import formatted_string_literals in Python <3.6?

We had from __future__ import print_function in 2.7, so could we have from __future__ import formatted_string_literals in, say, 3.4 and 3.5 (maybe even 2.7)?

Is there some policy that prohibits this, some technical reason, or just nobody got around tuit yet?

Ref: PEP 498: Formatted string literals

like image 916
frnhr Avatar asked Oct 24 '25 14:10

frnhr


2 Answers

Bringing f-strings to Python less than 3.6 is now covered at https://stackoverflow.com/a/46182112/8508004 . It is done via future-fstrings and simply requires a special line at the top of your code.

(I wanted to comment above but couldn't yet due to reputation restrictions for that.)

like image 164
Wayne Avatar answered Oct 27 '25 11:10

Wayne


from __future__ imports are used to introduce incompatible changes, f-strings are a new feature and not a breaking change.

like image 44
Daniel Avatar answered Oct 27 '25 11:10

Daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!