Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Indent your code blocks with 4 spaces.

I had this notion it formerly was 2 spaces (too little, IMH-once-bitten-O). Anyone know when it changed, if it did ?

P.S. In http://groups.google.com/group/django-developers/msg/f6a86d1... , back in Aug.2008, GvR says "Most of it [Google's unpublished internal Python style] is simply PEP-8 with 2-space indents."

(I dislike 2 spaces, once bitten by missing an indentation bug. I try to stick to 80 columns - both for print and side-by-side on screen - and think that more than 4 or 5 levels of indentation is "doing it wrong".)



I've always seen python style guides requiring 4 spaces. (With exceptions for 8!)

Ruby has standardized on 2 spaces.

I've noticed in my own experience that 2 spaces is not enough to read python quickly. 2 spaces works fine in ruby because whitespace isn't significant, you can find the end of a control structure by looking for the end keyword.


It was 2 spaces indeed when I first saw these guidelines (about a month ago)


Thanks, I suppose you mean the internal Google style. Curiously, in that Django thread I linked above, the next post mentions this: http://code.google.com/p/soc/wiki/PythonStyleGuide

Which is a style guide for the "SoC framework, and Melange web applications", updated Jun.2009; it does specify 2 spaces, duly noted as a difference from PEP-8.


What's wrong with 2 spaces? I like 2 spaces.


I like them too, the problem is when you want to use (paste) some code that is not yours - you need to re-indent it.


Then use 2 spaces. To me 2 spaces squishes code to close together. I like 4 spaces so that is what I use. You can always sift your code through a code formatter if there are differing standards on whatever project you are on.


Or just use tabs, so everyone can set the display to what they like (without actually rewriting the file).

/me hides before the flames start :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: