Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You could also group related conditions, so that nested if's don't bloat the locals so much:

    speedIsSlow = dict(downstreamSlow = downstreamSpeed < 200, 
                       upstreamSlow = upstreamSpeed < 100)
    
    if any(speedIsSlow.values()):
        connectionIsDead = getPingTime() > 100
        if connectionIsDead:
                print("It's dead, Jim")


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: