Python Mystery Theatre -- Episode 1: Exceptions
Aahz
aahz at pythoncraft.com
Sat Jul 12 10:40:34 EDT 2003
In article <3F0FC088.3C56EDEA at alcyone.com>,
Erik Max Francis <max at alcyone.com> wrote:
>Raymond Hettinger wrote:
>>
>> ACT III --------------------------------------------
>> >>> class Prohibited(Exception):
>> ... def __init__(self):
>> ... print 'This class of should never get initialized'
>> ...
>> >>> raise Prohibited()
>> This class of should never get initialized
>>
>> Traceback (most recent call last):
>> File "<pyshell#40>", line 1, in -toplevel-
>> raise Prohibited()
>> Prohibited: <unprintable instance object>
>> >>> raise Prohibited
>> This class of should never get initialized
>>
>> Traceback (most recent call last):
>> File "<pyshell#41>", line 1, in -toplevel-
>> raise Prohibited
>> Prohibited: <unprintable instance object>
>
>Is this some IDLE-specific thing?
Nope, the point here is that
raise Prohibited
will always create a Prohibited() instance. (See also Peter's post
about One True Way for exceptions.)
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"Not everything in life has a clue in front of it...." --JMS
More information about the Python-list
mailing list