raise Exception or raise Exception()

Chris Rebert clp2 at rebertia.com
Sun Nov 14 19:14:47 CET 2010

On Sun, Nov 14, 2010 at 8:58 AM, ernest <nfdisco at gmail.com> wrote:
> I have seen both forms and I'm not sure if they're
> both correct, or one is right and the other wrong.

They're both acceptable (although obviously you should always raise a
more specific error than Exception).
`raise SomeException` is in fact equivalent to `raise SomeException()`.
Providing an error message is always advisable though, so really in
most cases you ought to `raise SomeException("Informative error


More information about the Python-list mailing list