4 ms·
Interestingly, the Python code I've seen from Google uses 2-space indents rather than 4 as the style guide recommends. And that includes code written by Guido h
by waleedka 14y ago
Interestingly, the Python code I've seen from Google uses 2-space indents rather than 4 as the style guide recommends. And that includes code written by Guido himself (AppStats and NDB, tools used in App Engine). I prefer 2 spaces as well, and I was hoping that the official style guide would match what's being used most commonly.
- rachelbythebay 14y agoOne easy way to break your brain is to work at Google... on an open source Python project. Two, four... two, four... It could be far worse.
- AncientPC 14y agoI don't mean to start yet another tabs vs spaces debate, but I've always felt spaces dictate how others see the code while tabs allowed others to see code however they like (2/4/8 spaces). One exception is some projects are strict about lining up code properly in multi-line statements, and spaces are more consistent in that respect. I prefer tabs, but most Python code I've seen has been 4 space indents.
- toyg 14y agoI used to prefer tabs (less bytes, better abstraction etc), but I've long given up on it. Most tools are not smart enough to switch mode when required, and reformatting entire files every time you want to make a small change on somebody else's code is a real pain (and dangerous). Community consensus is 4-spaces and that's it.
- raverbashing 14y agoYeah I used to prefer tabs as well, and I still stand by it. But you can always configure your editor to use 4 spaces. And 4 spaces looks like 'less wasted space'. I'll keep using tabs for some things, and 4 spaces to most professional projects. About 2 spaces I'll just say one thing: NO
- sswezey 14y agoSublime text 2 can do it no problem, back and forth, and has visual indicators of tab levels regardless if it's spaces or tabs, 2 columns, 4 columns or 8 columns.
- kami8845 14y agoThey used to recommend 2 spaces (you can probably check the page with archive.org) but have switched to 4.
- Locke1689 14y agoThis is very weird, because the internal style guidelines say 2 spaces, not 4 spaces. This bugs me quite a lot.