Rob Cliffe wrote:
> Yes, exactly like that.
> I wasn't aware of __subclasses__ (it doesn't appear in
> dir(ArithmeticError),
> for example)

Slight tangent: dir() usually includes class attributes (e.g.
"set(dir(1)) >= set(dir(int))"), but to prevent weirdness that
particular feature is omitted for the metaclass of a type. So
dir(type(cls)) may reveal a few extra methods/properties (such as mro()
and __subclasses__()) that aren't listed when doing dir(cls).

> but if my suggestion were adopted, __subclasses__ would be
> just what is needed to implement it.

Restricting it to just builtins would be tricky, especially for
Exception (even without importing any additional libraries,
Exception.__subclasses__() lists 23 direct subclasses at the interpreter
prompt for me).

Anyway, as Michael suggested, a feature request on the bugs.python.org
tracker is the best way forward. That's no guarantee that anyone will
pick it up and run with it, but at least it will record the idea.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to