Created
July 29, 2011 23:55
-
-
Save pydanny/1114993 to your computer and use it in GitHub Desktop.
The better way keeps me happy when dealing with complex code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def sucky_way(x, y): | |
| """ This sucks when the nesting gets deep""" | |
| if x: | |
| return 'Too hard things get all nested and stuff' | |
| else: | |
| y += 1 | |
| return y | |
| def better_way(x, y): | |
| """ Makes pydanny happy""" | |
| if X: | |
| return 'Keeping it clean' | |
| y += 1 | |
| return y | |
Author
I learned the latter way during my Java days. It made dealing with giant nested ifs much easier. Same goes for the sort of Python I'm noodling through now. I'm paring and simplifying some really complex code into something legible and manageable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://ssdl-wiki.cs.technion.ac.il/wiki/index.php/Spartan_programming