[Python-3000] Pre-peps on raise and except changes
Brett Cannon
brett at python.org
Wed Jan 24 00:24:45 CET 2007
On 1/23/07, Collin Winter <collinw at gmail.com> wrote:
> On 1/23/07, Brett Cannon <brett at python.org> wrote:
> > On 1/23/07, Collin Winter <collinw at gmail.com> wrote:
> > >This form has two sub-variants: ``E`` may be either an
> > > instance of ``BaseException`` [#pep352]_ or a subclass of
> > > ``BaseException``. If ``E`` is a subclass, it will be called with
> > > no arguments to obtain an exception instance.
> > >
> > > To raise anything else is an error.
> > > """
> >
> > I don't think that calling them a variant is right. You can only
> > raise subclasses of BaseException (which implicitly implies
> > BaseException itself). If you want to mention BaseException itself
> > that's fine, but there is no variant here; there is a single rule.
>
> You can raise both subclasses of BaseException and instances of
> subclasses of BaseException. Are you intended to make the latter
> illegal?
>
No, of course not. As long as BaseException is in the inheritance
tree you are fine.
I just realized I misread your paragraph and took E to represent an
exception class, not a nebulous object that could be an exception
class or instance.
-Brett
More information about the Python-3000
mailing list