Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fix f-strings breaking backward compatibility python 3.5/3.6+

I have found some code which is apparently designed for python 3.6.

For some reason I need to run that code in a python 3.5 environment. Supposedly, the two versions should be backward compatible. However, the original code abuses in f-strings, raising hundreds of errors in py35

do you know any tool to remove those fstrings, or a clean workaround?

like image 477
00__00__00 Avatar asked Mar 05 '26 15:03

00__00__00


1 Answers

You can't create a backward-compatible Python 3.6 piece of software if you're using f-String formatting. The reason for this is that it's a fundamental syntax feature, so "making" it compatible with Python 3.5, for example, would imply changing the Python 3.5 interpreter itself.

The only "clean workaround" I can think of is formatting the strings in a way that does not conflict the previous Python versions you want your software compatible with.

Hope this helps.

like image 56
Chris Avatar answered Mar 08 '26 04:03

Chris



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!