It provides a variable name for the exception inside the except
block:
>>> try:
... raise Exception('foo')
... except Exception, ex:
... print ex
... print type(ex)
...
foo
<type 'exceptions.Exception'>
I personally find the as
syntax more clear:
>>> try:
... raise Exception('foo')
... except Exception as ex:
... print ex
... print type(ex)
...
foo
<type 'exceptions.Exception'>
But the as syntax wasn't introduced until 2.6, according to answers in this question.