Re:PEP 308 and why I still hate Python
by userbinator on Thursday March 09, 2017 @09:57PM
(#13835967)
Python is an imperative language.
...as are many others with the conditional operator's operands in the normal (condition, true-case, false-case) order:
https://en.wikipedia.org/wiki/%3F:
I think being "functional" or otherwise has nothing to do with it. Even in imperative languages you must use expressions, and it is there that the conditional operator is most useful.
Re:PEP 308 and why I still hate Python
by pjvandehaar on Monday March 13, 2017 @09:28PM
(#13864198)
Yeah, this has nothing to do with FP. No idea what the parent was going for...
Re:PEP 308 and why I still hate Python
by nsaslideface on Thursday March 09, 2017 @09:56PM
(#13835962)
Indeed. I find the huge "some_method" example pretty much invalid because I'd assign that dict to a variable first, so the line would be a nicer "return my_dict if y else {}". What person, style guide or PEP is forcing anyone to write some_method's return statement?
I don't get the ideal of saving space and writing huge one-liners (that in Python you'd have to break up over more lines). As they say on IRC: "if you're worried about using too many lines, I can send you a file full of blank ones."
You've identified a real issue (the functional features work badly except as one liners), and a good fix (only use them as one liners).
I think the cause has everything to do with some poor choices around the parser and syntax, however, and nothing to do with its imperative nature as such.
As a practical matter, only use Python's functional features in one-liners.