Posts

Showing posts with the label Pep

Assignment With Line Continuation - Python

Answer : I don't think there is any problem with line continuation in Python. But sometimes I prefer this: big_variable['big_key']['big_value'] =( another_big_variable_that_pushes_line_over_79_characters ) It is useful in long expressions, too. Line continuation is a bit taboo, but not the end of the world. We must always strive to write code such that some other programmer down the line can understand what we were doing. Using the line continuation character \ is but one tool in our arsenal for achieving this goal of legibility. Naming conventions are another issue. As da Vinci said "Simplicity is the ultimate sophistication." If you can make variable names small AND understandable, then you are sophisticated ;-). It's too easy to just say var1, var2, var3 etc. Coming up with good names is a skill , which takes effort. Would you rather see a variable named ChiefExecutiveOfficerOfCompanysName or CEOName ? If you can combine if ...