Python try...except comma vs 'as' in except

Posted by peter on Stack Overflow See other posts from Stack Overflow or by peter
Published on 2010-03-29T04:16:56Z Indexed on 2010/03/29 4:23 UTC
Read the original article Hit count: 384

Filed under:
|

What is the difference between ',' and 'as' in except statements, eg:

try:
    pass
except Exception, exception:
    pass

and:

try:
    pass
except Exception as exception:
    pass

Is the second syntax legal in 2.6? It works in CPython 2.6 on Windows but the 2.5 interpreter in cygwin complains that it is invalid.

If they are both valid in 2.6 which should I use?

© Stack Overflow or respective owner

Related posts about python

Related posts about python-2.6