Help resolve a syntax error on 'as' keyword (python 2.5)
Xavier Ho
contact at xavierho.com
Tue Nov 3 08:24:08 EST 2009
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 msg:
^
SyntaxError: invalid syntax
#########
Well that's interesting. as isn't a keyword yet in Python 2.5.
This works though, and I think it fits the specification in the
documentation.
# input
try:
raise Exception("Mrraa!")
except Exception, msg: # Notice it's a comma
print msg
# output
Mrraa!
##############
Hope that helps,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091103/23108fec/attachment-0001.html>
More information about the Python-list
mailing list