Hello,<div><br></div><div>I am using things like:</div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 16px; "><pre style="overflow-x: auto; overflow-y: auto; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(238, 255, 204); color: rgb(51, 51, 51); line-height: 14px; border-top-width: 1px; border-right-width: initial; border-bottom-width: 1px; border-left-width: initial; border-top-style: solid; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-top-color: rgb(170, 204, 153); border-right-color: initial; border-bottom-color: rgb(170, 204, 153); border-left-color: initial; ">

<span class="k" style="color: rgb(0, 112, 32); font-weight: bold; ">except</span> <span class="ne" style="color: rgb(0, 112, 32); ">Exception</span> <span class="k" style="color: rgb(0, 112, 32); font-weight: bold; ">as</span> <span class="n">inst</span><span class="p">:</span></pre>

</span>and</div><div><br></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 16px; "><div class="highlight-python"><div class="highlight" style="background-color: rgb(251, 229, 78); "><pre style="overflow-x: auto; overflow-y: auto; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(238, 255, 204); color: rgb(51, 51, 51); line-height: 14px; border-top-width: 1px; border-right-width: initial; border-bottom-width: 1px; border-left-width: initial; border-top-style: solid; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-top-color: rgb(170, 204, 153); border-right-color: initial; border-bottom-color: rgb(170, 204, 153); border-left-color: initial; ">

<span class="k" style="color: rgb(0, 112, 32); font-weight: bold; ">with</span> <span class="nb" style="color: rgb(0, 112, 32); ">open</span><span class="p">(</span><span class="s" style="color: rgb(64, 112, 160); ">"myfile.txt"</span><span class="p">)</span> <span class="k" style="color: rgb(0, 112, 32); font-weight: bold; ">as</span> <span class="n">f</span><span class="p">:</span>
    <span class="k" style="color: rgb(0, 112, 32); font-weight: bold; ">for</span> <span class="n">line</span> <span class="ow" style="color: rgb(0, 112, 32); font-weight: bold; ">in</span> <span class="n">f</span><span class="p">:</span>
        <span class="k" style="color: rgb(0, 112, 32); font-weight: bold; ">print</span> <span class="n">line</span></pre></div></div></span><div>Things that seems to be new in python 2.6 and higher, however reading <a href="http://docs.python.org/tutorial/errors.html">http://docs.python.org/tutorial/errors.html</a> and this not clear when this new syntaxes appeared.</div>

<div><br></div><div>My trouble is that I want to make something similar above compatible with python 2.5, but when running python2.5 I got:</div><div><br></div><div>except Exception as msg:</div><div>                      ^</div>

<div>SyntaxError: invalid syntax</div><div> </div><div>If there's a way (e.g. from __future__ ..., inherited modified Exception class, etc) that could give a solution to keep my code in python 2.6 syntax as above but compatible with python 2.5, that would be appreciated.</div>

<div><br></div><div>Many thanks in advance,</div><div><br></div><div>Alan</div>-- <br>Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate<br>Department of Biochemistry, University of Cambridge. <br>80 Tennis Court Road, Cambridge CB2 1GA, UK.<br>

>><a href="http://www.bio.cam.ac.uk/~awd28">http://www.bio.cam.ac.uk/~awd28</a><<<br>
</div>