exception attributes

Andrew Dalke dalke at acm.org
Sun Aug 19 14:35:55 EDT 2001


Frederic Giacometti wrote:
>String exceptions refer to the exception value used when raising
>the exception.

Yes.

>But even then, string exceptions must be associated to an exception class,
>to which the above rule applies...

Sorry?  I don't understand.  What's the exception class in the following?

>>> try:
...   raise "test2"
... except "test1":
...   print "Test1"
... except "test2":
...   print "Test2"
... except "test3":
...   print "Test3"
...
Test2
>>>

(NB: this is all old-style Python exceptions.  Use class based
exceptions for new code.)

                    Andrew






More information about the Python-list mailing list