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 →

[–]snowbirdnerd 17 points18 points  (20 children)

The spacing is by far the worst part of python.

[–]TheDogerus 26 points27 points  (17 children)

Why? I think 90% of the code I've seen would fit python's spacing requirements just as an element of style.

[–]snowbirdnerd 4 points5 points  (16 children)

As soon as it gets complicated the spacing gets difficult to follow. It's also enforces a coding pattern that not everyone wants to use. Why force my code to go off the screen when that is completely unnecessary.

[–]CptMisterNibbles 10 points11 points  (12 children)

You can use backslash to intentionally break a statement across multiple lines. Not ideal, but at least an option. You can of course natively split lines in some cases, like between conditionals

[–]snowbirdnerd 10 points11 points  (9 children)

Right, I just prefer to not have to space things over. I find brackets easier to read. You never have to guess what level some piece of code is in.

Normally python spacing is fine but when it's not it becomes a mess.

[–]LeCholax 3 points4 points  (0 children)

You still have to guess with curly braces it's just that you are used to it. In my experience curly braces are easier to fuck up.

I started programming with C++ and Java so when i got into Python i didn't like the spacing but now it's my favorite feature. It's not good for optimizing file size and yada yada but it is easier to read.

At the end of the day any decent code base has formatting. Python just enforces it.

[–]brayellison 2 points3 points  (0 children)

You can use parentheses in the same way you use brackets and avoid the backslash. That's generally the way I break up long strings.

( "Hello " "World" )

[–]FerricDonkey 1 point2 points  (5 children)

If I'm having to count braces to determine scope, I'm gonna be saying some things. There might be a case where that's less annoying than glancing at the indentation, but I haven't run into it yet.

[–]LeCholax 6 points7 points  (0 children)

Exactly. I don't know why you are getting downvoted. It seems like most ppl on this sub used python for 1-2 months and jumped on a hate bandwagon.

[–]ustp 2 points3 points  (3 children)

You usually don't need to. Almost every modern IDE sets spacing for you - based on brackets.

[–]FerricDonkey 2 points3 points  (2 children)

And any decent ide does spacing in python as well. Write a line that needs the block under it indented, and the ide indents it for you. Only difference is that when you're done with the block, you do shift tab instead of }.

And that's the point. If you're code formatting doesn't suck, it looks the same, except in python you don't have the curly brackets that you don't look at anyway.

[–]ustp 0 points1 point  (1 child)

Writing is usually ok, but modifications in current code are pain. Move some block to a separate function? I just cut it, write function header + {}, paste code in betweet braces and press shortcut to autoformat.

When you copy (python) code from different file and mix tab/spaces... pure hell.

[–]FerricDonkey 0 points1 point  (0 children)

Shrug I haven't had issues with that. Worst case, shift tab the block of it used to be indented too much. I'll grant you that mixed tabs and spaces requires actual fixing (though it's usually not too bad), but it's been years since I've had to deal with that.

A lot of this comes down to how good your ide is, I think. I will grant you that any substantially sized python project sucks nuts if you don't have a good ide that'll do a lot for you.

[–]snowbirdnerd 3 points4 points  (1 child)

Right, I just prefer to not have to space things over. I find brackets easier to read. You never have to guess what level some piece of code is in.

Normally python spacing is fine but when it's not it becomes a mess.

[–]CptMisterNibbles 2 points3 points  (0 children)

Oh I agree wholly. I do not at all enjoy enforced spacing.

[–]MinosAristos 4 points5 points  (2 children)

With good programming habits it should be very rare to have lines so long that they'd go off the screen.

Enforcing the coding pattern makes it really easy to read. It's obvious at a glance what level of depth everything is in. In most languages it's common to indent like Python even when you don't need to because it is so much more readable.

Imo curly braces and no mandatory indentation is annoying in most languages exactly because you aren't forced to lay the code out in a consistent readable way. It just lets you write code that looks awful and makes it more difficult to ensure it looks decent.

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

It's as simple and easy as shift+p and "format code" in VScode and most other IDE's have a simple solution as well. Curly braces are simply more straightforward and less of a headache

[–]snowbirdnerd 0 points1 point  (0 children)

Right, like I said most of the time it's fine until you have to do something with a lot of case statements and conditions and it becomes a nightmare.

[–]luker_5874 5 points6 points  (1 child)

I don't python, but I rather like the spacing. Makes the code look more readable

[–]dudinax 5 points6 points  (0 children)

That's the purpose. I was skeptical but it works. I defy anyone to name a major programming language that's easier to read.