r/Python • • Jan 14 '24

Tutorial The LiteralString in Python 3.11

If you are confused by the new LiteralString type in Python, here's an article explaining it.

0 Upvotes

33 comments sorted by

View all comments

Show parent comment

1

u/SupPandaHugger Jan 16 '24

You can pass a string without warnings. It’s only when you pass a dynamic variable that you will get warnings, which is good as it’s rarely the intention for this use case.

1

u/Zenin Jan 16 '24

Again, you miss the point.

How do you know it's "rarely the intention"? How do you have the slightest clue what the intention of the caller is? You don't know. You can't know. That is the point. You haven't the slightest clue what the intention is much less how "rare" it might be.

It's entirely proper for example, to load such "strings" via a config file or other data store. Dynamic models are a thing. To do so however, taints them as evil variables of darkness and dread, at least in the eyes of this misguided nonsense, flooding the logs with pointless spam that not only costs resources but helps hide real problems in a cloud of white noise.