[Python-Dev] Re: PEP-317
Greg Ewing
greg@cosc.canterbury.ac.nz
Tue, 10 Jun 2003 12:17:01 +1200 (NZST)
Steven Taschuk <staschuk@telusplanet.net>:
> Btw, just to be clear: in pure Python, deferred instantiation is
> already impossible; implicit instantiation is exactly equivalent
> to explicit.
I know that's the way it *is*, but I can't see any reason why the
interpreter couldn't defer instantiation if it wanted to. It should be
an optimisation that any part of the implementation is free to make if
the programmer hasn't explicitly instantiated before raising.
> In this plan, in order to raise, say, a TypeError with deferred
> instantiation and no arguments, you'd have to write
>
> raise TypeError, ()
Hmmm, yes, it would appear so. I must admit that does look
a bit ugly.
But something else has occurred to me. If we're going to require
exception classes to be derived from Exception, then there's no
ambiguity anyway, because you can't have an object which is both a
subclass of Exception and an instance of a subclass of Exception. (At
least not without pulling some sort of bizarre trick, and I don't
much care what happens to anyone who does that.-)
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg@cosc.canterbury.ac.nz +--------------------------------------+