3 ms·
I'll just leave this here: https://www.python.org/dev/peps/pep-0020/ https://www.python.org/dev/peps/pep-0020/ "There should be one-- and preferably only one -
by monkmartinez 11y ago
I'll just leave this here: 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."
There are a lot of warts on that snake, but I still really like using Python.
- aexaey 11y agoPEP20 sound amazing, but then when this only way end up being way too verbose/ugly, you are kind of stuck with it. Compare: #python import re m = re.search('(a.+)(d.+)', 'abcdef') if m: print(f"{m.group(1)},{m.group(2)}") #perl if('abcdef' =~ /(a.+)(d.+)/){ print "$1,$2"; }
- JoshTriplett 11y agoI don't know why Python re match objects don't support indexing; a __getitem__ method would allow m[1] and m[2] instead (or m['name'] for named groups). That aside, though, I don't consider brevity alone the most critical criteria for a programming language; that way lies APL. Expressiveness, yes, but not at the expense of clarity.
- eugenekolo2 11y agoPreferably one. Unfortunately they put in `format`, and can't remove it now. I think moving towards f-strings is a lot better and should be embraced.
- mixmastamyk 11y agoFormat is still needed for non-literals and user objects, this is just an extension of it.
- orf 11y agoThere are a couple of warts for sure, but Python is remarkably wart free. Compare it to something wart ridden like PHP or JavaScript.
- mixmastamyk 11y ago"Practicality beats purity."
- sametmax 11y agokeyword is "preferably". Also "Simple is better than complex", "practicality beats purity" and "Readability counts". The zen is not the bible, you don't get to cherrypick the stuff you want to make your case. Plus, they are just guide lines, in the end, you have a debate in the python dev mailing list with reasonable people making their case.