maraujop / requests-oauth

Python's Requests OAuth (Open Authentication) plugin
BSD 3-Clause "New" or "Revised" License
188 stars 33 forks source link

Refactoring and normalization of boolean statements #27

Closed jjmaestro closed 12 years ago

jjmaestro commented 12 years ago

The initial structure was:

if a:
    if b:
        print '1'
    else:
        print '2'
else:
    if b:
        print '1'
    else:
        if c:
            print '3'
        else:
            print '4'

which can be clearly simplified to

if b:   
    print '1'       
elif a:
    print '2'       
elif c:
    print '3'
else:
    print '4'

Thus, the refactor :) In my opinion, it simplifies the whole conditional flow quite a bit and that's always nice :D

maraujop commented 12 years ago

Merged, thanks for the Patch Javier.

Cheers, Miguel