raise Exception or raise Exception()
roy at panix.com
Sun Nov 14 21:14:00 CET 2010
In article <mailman.989.1289758489.2218.python-list at python.org>,
Chris Rebert <clp2 at rebertia.com> wrote:
> 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()`.
I've always found this rather disconcerting and unpythonic. Sure, it
saves a couple of keystrokes here and there, but it also adds confusion
such as Ernest's. It reminds me of Perl's letting you omit the
parentheses on function calls.
More information about the Python-list