How to avoid nested try-s of increasing complexity/indentation in Python
<p>I have code like this:</p>

<pre><code>try:
    request=parse_request
except:
    print "cannot parse your malformed request"
    exit()
else:
    try:
        fh=a_factory_function()
    except:
        print "cannot create object"
    else:
        if request['operation']=='search':
            pass
        elif request['operation']=='more_like_this':
            pass
        elif request['operation']=='list_files':
            pass
        elif request['operation']=='update':
            pass
        else:
            print 'unsupported operation'
</code></pre>

<p>In present form it has two levels of indentation</p>

<ol>
<li>parse a request</li>
<li>the factory function to generate an object to process the request</li>
</ol>

<p>I can easily imagine this getting to 4 levels and becoming too complex for our puny reasoning. Is there a Pythonic way to flatten the indentation and make it "linear"?</p>
