Hacker News new | ask | show | jobs
by thoutsnark 713 days ago
I strongly agree with your main point that pythons syntax design is objectively poor, but content that even the grace you seek to extend to it is wrong

>Python encodes structure in only one way, using indentation

Except when you write a multiple line string using """ notation.

Or when you put things inside parenthesis, which i have seen as the preferred solution for method chaining.

Point is, python claims indentation is all that is needed, and then very quickly breaks it's own rule.

1 comments

Open parentheses and "multi-line" strings are simply Python's way to allow a single statement to span multiple lines in a nicer way: incomplete expressions continue across the newline (you can also do that with a common Unix way of escaping the newline — backslash right before you start the new line). FWIW, even """ notation does not require a string to be multi-line — it mostly allows using less escaping for things like newlines but also quotes.

A preferred way to chain methods is to store values in descriptively named intermediate variables: it would also ease debugging as you'll get a direct pointer to the line that is problematic. Though, TBH, that's probably bad API design (I know it's common with DB query syntax, but that's attempting to turn SQL query construction into objects when they really aren't).

Python, like most languages, doesn't really stop you from doing crazy stuff. But also like most languages, it can be done really well.