pylint -- should I just ignore it sometimes?

Shawn Milochik shawn at milochik.com
Tue Oct 19 17:34:40 EDT 2010


Just to be pedantic (or maybe even helpful), the use of the comma
after the exception is deprecated in favor of 'as.'

So:

except ValueError as ex:

not:

except ValueError, ex:

I don't know how far back in Python versions this syntax reaches, but
if yours supports it then it's probably a good idea to get into the
habit.
This way, you can catch multiple exceptions in a tuple without
confusing the interpreter:

except ValueError, IndexError as ex:

Shawn



More information about the Python-list mailing list