3 ms·
Do they? All the Python folks I've ever seen express an opinion on style have said "follow PEP 8". Unsurprisingly, PEP 8 does have a rule for tabs vs. spaces:
by tom_mellior 9y ago
Do they? All the Python folks I've ever seen express an opinion on style have said "follow PEP 8".
Unsurprisingly, PEP 8 does have a rule for tabs vs. spaces: https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces (spaces, of course)
- jwilk 9y agoAs a data point, I don't follow (all of) PEP-8. But tabs vs. spaces is indeed a bad analogy, because of course it's 4 spaces. ;-P pycodestyle, the Python style checker, has a few checks disabled by default (because there's no consensus they're good ideas), and even some mutually exclusive ones: https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes https://pycodestyle.readthedocs.io/en/latest/intro.html#erro...
- sireat 9y agoI love Python but as a long time C programmer I can't understand the preference for spaces in PEP 8. Tabs are semantic and only take one key press for movement back and forth and to delete. If you see 1 tab you know it meant one indentation level. With spaces you have to think. Plus with spaces you are stuck with 2/4/8 spacing(unless you reformat), with tabs you can configure your editor to your preferences.
- slaman 9y ago> with tabs you can configure your editor to your preferences. Configure 1 tab to be 4 spaces. Sometimes it's easier to go with the flow. I like tabs for the reasons you mentioned, but fixed-width spaces are a bit better for some reasons too. IDE's can do the heavy lifting of re-formatting indentation levels and converting tabs to spaces for me, and it means if I cat a file on a remote server regardless of the bash tab width settings or if I'm in your code or the stdlib it will all make sense.
- e12e 9y agoTabs are semantic. But, when you start down that route, why not dictate record-separotor as replacement for closing brace/block etc?
- tom_mellior 9y ago> with tabs you can configure your editor to your preferences Except that you can't because people using tabs will invariably start mixing tabs and spaces because they can't separate indentation from layout. So the code will be messed up unless you configure your editor to someone else's preferences. Also, I'm sure there is some obscure git setting to de-uglify tab users' diffs, but I'd rather not find out.
- pleasecalllater 9y agoThe PEP8 myth is quite funny. Almost all people I've met who were repeating "follow the pep8" like a mantra, have never read it. The main idea behind pep8 is: be consistent... however even the python library is not consistent. And it looks like no one cares. There was a great moment to make it nice and consistent - creating the python3, where many incompatible changes were introduced. Instead, the mess is like it was, and people repeat the mantra "follow pep8". Before you say that I'm crazy... please, go and read pep8.
- tom_mellior 9y ago> please, go and read pep8 OK. What am I looking for?