• Victor
          link
          fedilink
          135 months ago

          I thought python allowed whatever indentation you wanted as long as it’s consistent?

            • ℍ𝕂-𝟞𝟝
              link
              fedilink
              English
              115 months ago

              Python is one of the few languages with an official style guide, I think that guide says 4 spaces.

                • @nexussapphire@lemm.ee
                  link
                  fedilink
                  English
                  115 months ago

                  I’ve set tabs to four spaces in vim because who the fuck defaults tab to eight spaces. That shit looks alien and pushes text off the screen fast.

                  • Oscar
                    link
                    fedilink
                    English
                    8
                    edit-2
                    5 months ago

                    Linux uses 8 spaces. Excerpt from the official style guide:

                    Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

                    Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you’ve been looking at your screen for 20 straight hours, you’ll find it a lot easier to see how the indentation works if you have large indentations.

                    Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you’re screwed anyway, and should fix your program.

                    In short, 8-char indents make things easier to read, and have the added benefit of warning you when you’re nesting your functions too deep. Heed that warning.

                    The reasoning seems sound, but I still prefer 4 personally.

                  • @ulterno
                    link
                    English
                    45 months ago

                    I set my clang-format to tabs only (actual tabs ASCII 0x9, no alignment and there is a continuation tab instead), then anyone can set their editor to whatever tab length they feel like and look at their code however they want.

                    But no spaces on the left of my code. This is for C, C++ and JSON.

                • lad
                  link
                  fedilink
                  English
                  55 months ago

                  4 tabs is a bit overboard, don’t you think?

    • @Kojichan@lemmy.world
      link
      fedilink
      25 months ago

      I’d love to see your .editorconfig.

      What’s that in your project root? …pom.xml? Misread that at first as porn.xml.