Finally, I like how this style lends itself very naturally to refactoring the condition into its own variable, like so: This makes it easy to see the history with git-blame. ![]() And I also like how adding or removing clauses from the condition will only change a single line, (unless you remove the first condition, "some_super_long_condition"). It looks visually pleasant, (at least to me). What are some of the "advantages" of this style? Well, for one, I like how the code for the condition, True, and False branches all line up. But to be honest, most of the styles I've seen-even those that conform with the PEP-seem ugly and hard to read for me. ![]() PEP 8 gives a number of acceptable ways of handling multiple line if-statements in Python.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |