monica_b1998@lemmy.world to Python@programming.dev · 19 days agoPython String Formatting: f-strings vs .format() vs %slicker.meexternal-linkmessage-square15linkfedilinkarrow-up142arrow-down10
arrow-up142arrow-down1external-linkPython String Formatting: f-strings vs .format() vs %slicker.memonica_b1998@lemmy.world to Python@programming.dev · 19 days agomessage-square15linkfedilink
minus-squareMichal@programming.devlinkfedilinkarrow-up4·18 days agoMost importantly you can’t use them with translated strings, so it’s not usable for user facing strings unless you don’t care. This limits fstring usefulness a lot in the projects I work on.
minus-squareBadabinski@kbin.earthlinkfedilinkarrow-up8·18 days agoLuckily, there’s now t-strings (e.g. t"{buh}") for that use case (among many others). Here’s the PEP: https://peps.python.org/pep-0750/
Most importantly you can’t use them with translated strings, so it’s not usable for user facing strings unless you don’t care. This limits fstring usefulness a lot in the projects I work on.
Luckily, there’s now t-strings (e.g.
t"{buh}") for that use case (among many others). Here’s the PEP: https://peps.python.org/pep-0750/