|
|
|
|
|
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. |
|
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.