Raising objects

Alex Martelli aleax at aleax.it
Thu May 1 18:52:36 EDT 2003


Michael Chermside wrote:

>> > Allowing only [a] subclasses of (say) NewException, a hypothetical
>> > new newstyle class; or [b] classic classes, and [c] strings, to
>> > be raised, with b and c there only for backwards compatibility,
>> > is FAR simpler, neater, easier to explain, and more pragmatical.
>> 
>> For what it's worth, I agree with Alex that you should only be allowed
>> to raise these three things. The only thing I'd change would be the
>> name of NewException (and I'd only change it if I could come up with
>> a better name!).
> 
> Hmmm... I should clarify. I think that you should be allowed to raise
> subclasses of NewException AND instances of subclasses of NewException
> just as we allow today with classic classes.

Actually, I'm coming around to one of Steven's ideas -- sub [a] we
should only be allowed to explicitly raise *instances* of some
subclass of NewException (while sub [b] as long as bw compatibility
holds we need to stay able to raises classes OR instances).  There's
no real reason to have both "raise XX, x" and "raise XX(x)" mean
exactly the same thing -- it's only a recipe for confusion.


Alex





More information about the Python-list mailing list