this post was submitted on 17 Aug 2024
695 points (94.8% liked)

Programmer Humor

33268 readers
998 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 5 months ago (8 children)

I once wrote a bot in python tdownloaded a ical file, looked for chances and informed me if found. The space indentation made it hell to follow the code in my opinion.

[–] naught 4 points 5 months ago* (last edited 5 months ago) (5 children)

Just curious, what about spaces made it hard? What language would have been easier? In curly brace languages, 99% of the time, a curly brace is followed by a line break and an indent. Python is similar except it's typically a colon, line break, then indent.

What I have learned is: If the code is indented too deeply, it's a code problem, not the language.

Torvalds infamously wrote:

"... if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program."

[–] [email protected] 2 points 5 months ago (1 children)

Torvalds wrote this about C. There's plenty languages where it's much more common and less of a complexity indicator to open up scopes.

[–] naught 6 points 5 months ago

Correct, I linked the source of the quote. My implication is the general idea is applicable here. Is python one of these languages where it is idiomatic to nest code deeply?

The Zen of Python:

Flat is better than nested.

From the python I have seen and written, deep nesting is avoided.

load more comments (3 replies)
load more comments (5 replies)