En Tue, 03 Nov 2009 10:06:24 -0300, Oltmans
escribió:
Hi, all. All I'm trying to do is to print the error message using the
following code (copying/pasting from IDLE).
try:
div(5,0)
except Exception as msg:
print msg
SyntaxError: invalid syntax
I'm using Python 2.5 on Windows XP.
Oltmans writes:
> try:
> div(5,0)
> except Exception as msg:
> print msg
The name ‘msg’ here is misleading. The except syntax does *not* bind the
target to a message object, it binds the target to an exception object.
It would be clearer to write the above code as:
try:
div
Vladimir Ignatov wrote:
> Hi,
>
> "except Exception as variable"
>
> is a new python-3 syntax.
>
> You should use "except Exception, variable" syntax in 2.x series.
Not entirely true. This feature has been backported to python2.6 as well.
Diez
--
http://mail.python.org/mailman/listinfo/pytho
I don't have Python 25 on my computer, but since codepad.org is using Python
2.5.1, I did a quick test:
# input
try:
raise Exception("Mrraa!")
except Exception as msg:
print msg
# output
t.py:3: Warning: 'as' will become a reserved keyword in Python 2.6
Line 3
except Exception as ms
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 wrote:
> Hi, all. All I'm trying to do is to print the error message using the
> following code (copying/pa