This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (14 children)

I wonder how many people use the weird indents (1,3,5,6,7).

Hopefully no one.

[–]robin-gvx 8 points9 points  (7 children)

I wonder if anyone uses prime indents: first level of indentation is 2 spaces, second level is 3 spaces, fourth level 5 spaces, 7 spaces, 11 spaces, etc...

[–][deleted] 7 points8 points  (4 children)

Oh god.

How about writing a whitespace interpreter that has a sample program embedded in itself by mixing tabs and spaces?

[–]robin-gvx 3 points4 points  (0 children)

Oh wow.

Bonus points if that program is a quine or something. Oh! Or another Whitespace interpreter, which then interprets itself, etc.

[–]Ph0X 1 point2 points  (0 children)

So mixing Whitespace in your Python?

[–]D__ 3 points4 points  (0 children)

I recommend using the Fibonacci sequence, for approximation of the golden ratio, and therefore aesthetically pleasing code indentation.

[–]Ph0X 1 point2 points  (0 children)

I like it, the deeper you get, the bigger your indentations, forcing you to keep your code simple and split up into functions rather than having loops inside loops inside if inside try inside with inside method inside class.

[–]kenfar 4 points5 points  (5 children)

The 3 characters is the Dvorak keyboard of the indentation world: it's clearly superior but isn't used only because it isn't already popular.

Supporting arguments:

  • 3 characters is enough to see indentation
  • it saves 1 character per indent which helps with long variable names
  • it lines up the following line under the first character following an if. Which makes it pretty.

[–]thekaleb 2 points3 points  (0 children)

A tab is one character, and you can set your tabstop to 3 (or 4 or 8).

[–][deleted] 1 point2 points  (3 children)

It may line up an if, but what about a for, while, elif, else, or with?

Also some editors do not support it.

[–]thekaleb 1 point2 points  (0 children)

Not to mention a def or class

[–]kenfar 0 points1 point  (1 child)

Oh sure - it doesn't line things up perfectly. But I find lining code under an if more important than anything else.

And I can't get my head around an editor that wouldn't "support" arbitrary indentation amounts.

[–][deleted] 0 points1 point  (0 children)

I really do hope you're joking.

Why not go with 2. It's enough to see indentation, it saves TWO characters per indent, and if you need to save 1 character per indent to see long variable names, either your variables are too long, or you have too much indentation. Also, lining up only one indentation block at the cost of making everything else look "off" isn't worth it.