6 ms·
The PEP document describing the feature: https://www.python.org/dev/peps/pep-0584/ https://www.python.org/dev/peps/pep-0584/
by kam 7y ago
The PEP document describing the feature:
https://www.python.org/dev/peps/pep-0584/ https://www.python.org/dev/peps/pep-0584/
- pansa2 7y ago> > Dict union will violate the Only One Way koan from the Zen. > There is no such koan. "Only One Way" is a calumny about Python originating long ago from the Perl community.
- wwright 7y agoFor what it is worth, from https://www.python.org/dev/peps/pep-0020/ https://www.python.org/dev/peps/pep-0020/: > There should be one-- and preferably only one --obvious way to do it. Personally, I’ve always thought that Python missed its Zen, both here and on “explicit is better than implicit.”
- ehsankia 7y agoThat ship had long sailed with string formatting anyways.
- saagarjha 7y agoIt sailed long before that.
- mokus 7y agoIt sailed with Turing completeness! At least, the popular interpretation of the phrase that ignores the word “obvious” did.
- orf 7y agoIt sailed when they added the for loop - everyone was happy using while loops, things worked and it was simple. Now there are TWO ways of calling a block of code repeatedly based? How confusing for new users. Python really went downhill since then.
- anon102010 7y agoI think go dropped one of these (for vs while) to keep to just one approach on loops so python providing lots of ways to do same thing is something other languages targeting entry level folks are seeking to avoid
- pwdisswordfish2 7y agoAh, so that's what the migration to Python 3 was all about!
- eesmith 7y agoGo back to 1.0 and we still had two ways to write strings ("abc" and 'abc'), and two ways to write not equal ("!=" and "<>"). The last died with 3.0. But my point is that the Zen of Python must be seen as a post hoc description overlaid onto whatever the actual Python philosophy is. Aligned, certainly, but at times only roughly aligned. So I don't see it as having sailed (with string formatting, or other specific even) but never having been there in the first place. More like, sailing in the same waters.
- orf 7y agoF-strings are the one obvious way to do string formatting. There may be other ways, for legacy backwards compatibility reasons, but f-strings are the way to do string formatting.
- kzrdude 7y agoI think you are right. Just left a string of legacy (%-formatting) and dead end (.format()) solutions on the way there.
- cochne 7y agoI disagree. In logging for example, ‘%s’ with the value as an argument to the logger is preferred because the formatting can be ignored if the log level is not sufficient to print.
- orf 7y agoLog formatting is a different problem than string formatting. With log formatting you pass the formatting arguments as function parameters, which is completely different from any other way you format strings.
- AlexandrB 7y agoI think you're getting downvoted because logging is basically doing: def log(fmt, *args): print(fmt % args) Hardly a huge change.
- heavenlyblue 7y agoExcept log formatting isn’t the same as actually executing the expression passed to the logging function.
- mixmastamyk 7y agoYes, unless a template is needed later. That's why the others continue to exist.
- AlexandrB 7y ago