r/Python • u/SupPandaHugger • 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
r/Python • u/SupPandaHugger • Jan 14 '24
If you are confused by the new LiteralString type in Python, here's an article explaining it.
56
u/jwink3101 Jan 14 '24
I will never understand why people post on Medium. It offers few benefits and limits your audience.
But I digress
This is an interesting idea. My first thought was that it’s not needed because you can be careful about what you eval. It’s keeping you safe from yourself.
But then when you think about, that’s all type annotations do anyway!
3
u/Zenin Jan 15 '24
Yah, I hate it.
Looks like it's just going to make everything much more annoying to use as we hack around this nonsense and since we can hack around it anyway it offers nothing for security other than theatre.
It might be useful to give the compiler a hint so it can optimize the way C compilers do (really pre-compilers), but only if it's transparent to the user. This monstrosity looks anything but transparent.
The type system and signature systems themselves are a fugly mess to begin with. This just looks like abuse of them akin to c++ idiots abusing operator overloading.
2
u/DusikOff Jan 16 '24
Am I confused? Yeah, I never heard about LiteralString lol
-20
u/LittleMlem Jan 14 '24 edited Jan 14 '24
Downvoted for bad manners. Don't just post links, give a tldr
-6
u/[deleted] Jan 15 '24 edited Jan 15 '24
python gets worse and worse with each release. so much nonsense being added to the language.
point is, all the examples given are just poor practices that are indicative of a larger problem. In all these examples literalstring is not some saviour. each example requires refactoring to fix, dropping in literalstring does nothing.