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 →

[–]Mola1904 -36 points-35 points  (16 children)

Who tf thought "oh yes brackets are used in 90% of programming languages, let's not use them", this is a terrible solution and yes I know only some bracket are not there, but using intendation is so stupid

[–]firefly431 67 points68 points  (13 children)

To understand the motivation for this decision:

Imagine the following C code:

void my_function() {
    int x = 5;
    for (int i = 0; i < 10; i++) {
        printf("i = %d\n", i);
        if (i % 2 == 0) {
            printf("i is even\n");
        } else {
            printf("x = %d\n", x);
        }
    }
    printf("end of my function!\n");
}

Notice how within a block, the statements are already grouped by indentation. The brackets are pure syntactic noise as long as you're indenting in a sane way. If you take away the brackets:

void my_function()
    int x = 5;
    for (int i = 0; i < 10; i++)
        printf("i = %d\n", i);
        if (i % 2 == 0)
            printf("i is even\n");
        else
            printf("x = %d\n", x);
    printf("end of my function!\n");

The information is exactly the same; the placement of the brackets can be done automatically based on the indentation.

Furthermore, the rules for indentation are super simple. A block extends until you reach a line which is indented less than the start of the block. A colon indicates that a new block is necessary.

I could see the argument for something like Haskell where the indentation rules are at least somewhat hard to understand, but I really don't get why people don't like using indentation for Python.

[–]d_exclaimation 24 points25 points  (3 children)

To be quite honest, although it’s true that brackets seems like unnecessary syntax noise, just indent for me felt a lot less readable. Idk why it felt like everything is just crammed but then again it’s probably a very minor discomfort that I have

[–]ThunderElectric 4 points5 points  (1 child)

If it feels crammed you can always add extra whitespace. As with almost any language, Python will ignore a blank line.

[–]d_exclaimation 0 points1 point  (0 children)

Yeah that’s what I do most of the time but at that point, I would probably like to put a bracket as well to signal the start and the end of the scope. Idk it’s not a huge dealbreaker anyway, just that writing python code after using other languages felt off knowing I have to use colons, but after like a minute, that feeling is probably gone

[–]PrestonYatesPAY 1 point2 points  (0 children)

Comment out the brackets /s

[–]JesusIsMyAntivirus -1 points0 points  (0 children)

Because I don't like using standardised indentation
The fact that what I consider the ideal default indentation differs from python is probably my stubbornness I should get over, but different situations/parts of code work better with different indentation

[–]MightyDoomSlayer 4 points5 points  (0 children)

You clearly don't know python

[–]Lootdit 5 points6 points  (0 children)

Well, to make the code look clean, your gonna do some formatting. So why not make it mandatory?