Exception handling

Philip Swartzleonard starx at pacbell.net
Wed May 8 08:06:19 EDT 2002


Michael Hudson || Wed 08 May 2002 04:37:28a:

>> Also, what about raising things like strings as exceptions (which
>> i've done in exapmle classes for CIS/DS projects, e.g. 'Raise
>> "Linked list is empty, please verify with is_valid"' or whatever
>> just for documention really).
> 
> That's very backward behaviour; string exceptions fell out of favour
> with Python 1.5 (I think; might have been 1.4 or even earlier).  You
> can still do this, but you shouldn't in new code.

Yeah, it was just a demonstration though, that's why I used it.

> Not sure what "things like strings" means; try raising anything other
> than a string or an (old-style!) instance and you'll get a TypeError
> instead.
> 

Hm, you can't 'raise 5' or anything? Or anything derived from object? 
That's kind of wierd.

-- 
Philip Sw "Starweaver" [rasx] :: www.rubydragon.com



More information about the Python-list mailing list