Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Google App Engine source uses tab depth 2

Looking through the Google App Engine source, I noticed that the tab depth is 2 spaces instead of the conventional 4. Is there some wisdom behind this, or is it just someone's preference?

(Maybe it's trivial, or maybe Google knows something that isn't immediately obvious.)

UPDATE I wasn't suggesting that it ran differently based on the tab depth. But perhaps there's a good reason for their style.

like image 580
Nick Heiner Avatar asked Mar 20 '26 09:03

Nick Heiner


1 Answers

The Google Python Style Guide is published here, and, besides being generally vaster than PEP 8, it also differs from it in some aspects. However, the published version of the guide does mandate 4-space indents (like PEP 8 and like just about everybody else does).

Within Google, however, the actual rule is two-space indents (and you'll often catch me posting 2-space indented code because (a) it's habit by now, and (b) it's how my editors are set up;-). This was historically derived from the Google C++ style guide (Google used both C++ and Python essentially from day one, but I think C++ got its formal style guide first), which says

Spaces vs. Tabs

▽ Use only spaces, and indent 2 spaces at a time.

Lots of googlers code in both C++ and Python all the time, so I guess keeping minor aspects of the two style guides in sync, where feasible, is considered a productivity enhancement.

like image 177
Alex Martelli Avatar answered Mar 23 '26 03:03

Alex Martelli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!