<div>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt">Hi,</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> </span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt">I'm getting issues with try / except blocks in VS 2008, particularly with the following way of catching the errors:</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> </span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt">try:</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> something</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt">except Error as e:</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> do something with e</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> </span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> </span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt">When I try this directly from the IPY console it works fine:</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> </span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt">>>> try:<br>... open(fakefile.txt)<br>... except NameError as e:<br>
... print 'E is: ' + `e`<br>...<br>E is: NameError("name 'fakefile' is not defined",)</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> </span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt">When entering the same code into Visual Studio 2008, it doesn’t like the syntax at all and highlights the 'as e' part as a syntax error.</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> </span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt">Has anyone seen this before and know a way around it at all please? As it works in the IPY console and is valid Python, I'm presuming it is a bug within VS?</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> </span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt">Thanks,</span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt"> </span></p>
<p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt" class="MsoNormal"><span style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt">B</span></p></div>
<div> </div>