Help resolve a syntax error on 'as' keyword (python 2.5)
Vladimir Ignatov
kmisoft at gmail.com
Tue Nov 3 08:19:15 EST 2009
Hi,
"except Exception as variable"
is a new python-3 syntax.
You should use "except Exception, variable" syntax in 2.x series.
Vladimir Ignatov
On Tue, Nov 3, 2009 at 4:06 PM, Oltmans <rolf.oltmans at gmail.com> wrote:
> Hi, all. All I'm trying to do is to print the error message using the
> following code (copying/pasting from IDLE).
>
> def div(a,b):
> print a/b
>
>
> try:
> div(5,0)
> except Exception as msg:
> print msg
>
> but IDLE says (while highlighting the 'as' keyword)
> except Exception as msg:
>
> SyntaxError: invalid syntax
>
> I've searched the internet and I'm not sure what can cause this. Any
> help is highly appreciated. I'm using Python 2.5 on Windows XP.
More information about the Python-list
mailing list