Why "class exceptions" are not deprecated?

Fredrik Lundh fredrik at pythonware.com
Tue Mar 21 14:33:47 EST 2006


Gregory Petrosyan wrote:

> 1) From 2.4.2 documentation:
> There are two new valid (semantic) forms for the raise statement:
> raise Class, instance
> raise instance
>
> 2) In python:
> >>> raise NameError
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> NameError
> >>> help(NameError)
> Help on class NameError in module exceptions: ...
> >>> raise 0
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: exceptions must be classes, instances, or strings
> (deprecated), not i
> nt
>
> So, if it's a bug in documentation, it should be corrected. Otherwise,
> (IMHO!) raising classes should be deprecated.

it could be that the tutorial author expected you to read chapter 8
before you read chapter 9, and used "new" to mean forms that hadn't
already been described:

    http://docs.python.org/tut/node10.html

> Does raising class make sence? As for me, I can't find any usefull
> case for it.

as explained in the language reference,

    raise Class

is the same thing as

    raise Class()

</F>






More information about the Python-list mailing list