3 ms·
You should try inverting that code with guard statements: def frob(someargs): if something <= 2: return # do some processing if th
by gte910h 15y ago
You should try inverting that code with guard statements:
def frob(someargs):
if something <= 2: return
# do some processing
if that != "CONNECT": return
if verdict not in blessedsolutions: return
print "Happy birthday!"
Code Complete 2 suggests this for many types of logic when overly deep nesting bites you.