4 ms·
There's actually five now! 1. manual string concatenation 2. the old, printf-style. Still heavily used in e.g. stdlib logging module. 3. .format() 4. f-strings
by doteka 7y ago
There's actually five now!
1. manual string concatenation
2. the old, printf-style. Still heavily used in e.g. stdlib logging module.
3. .format()
4. f-strings
5. string.Template in the stdlib
Yup, I definitely see this as one of the bigger failures in Python's design.
- BiteCode_dev 7y agoIt's a problem, but not a failure in design. The language is old. It started with features from that times and evolved to add more modern ones. Removing the old ones would break the world. Why do you thing you can still use == and declare vars without keywords in JS ? Even in the p3 transition, the community screamed to not remove them. Did you know we removed % for a few versiond ? We had to put it back because of all the complaints.
- guitarbill 7y agoin practice it's 3. and 4. though. we outright ban 2. through a linter. it not only looks ugly, but is inconsistent. e.g. it has the tuple pitfall with a (language?) hack to make it work with one variable. even for logging, it's possible to use the `.format` style - although this isn't default. i've never seen `string.Template` actually used, except for niche use-cases with untrusted input, where a full-blown templating engine was overkill.