(original) (raw)

----- Original Message -----
From: "Aur�lien Campeas" <aurelien.campeas@logilab.fr>
To: "Rob Cliffe" <rob.cliffe@btinternet.com>
Sent: Wednesday, April 21, 2010 5:25 PM
Subject: Re: \[Python-Dev\] Small suggestion re help(Exception)


> like in
>
>>>> ArithmeticError.\_\_subclasses\_\_()
> \[<type 'exceptions.FloatingPointError'>, <type
> 'exceptions.OverflowError'>, <type 'exceptions.ZeroDivisionError'>\]
>
> ?

Yes, exactly like that.
I wasn't aware of \_\_subclasses\_\_ (it doesn't appear in dir(ArithmeticError),
for example), but if my suggestion were adopted, \_\_subclasses\_\_ would be
just what is needed to implement it.
Rob Cliffe


>
> Le mercredi 21 avril 2010 � 17:17 +0100, Rob Cliffe a �crit :
>> help() on an Exception class lists the method resolution order
>> (effectively the inheritance hierarchy).
>> E.g. help(ArithmeticError) displays inter alia:
>>
>> Method resolution order:
>>     ArithmeticError
>>     StandardError
>>     Exception
>>     BaseException
>>     \_\_builtin\_\_.object
>>
>> Would it be possible for it also display the Python built-in
>> SUBclasses of the class?  E.g. in the same example something like:
>>
>> Built-in subclasses:
>>     FloatingPointError
>>     OverflowError
>>     ZeroDivisionError
>>
>> This may seem pointless to grizzled old Python veterans who (maybe)
>> know the inheritance hierarchy backwards, but for those of us with
>> less experience I think it would be helpful, e.g.
>> (1) It would help to track down an Exception whose name you have
>> forgotten.
>> (2) It would sometimes be illuminating, e.g. LookupError might be a
>> bit obscure at first, until you see that it is the superclass of the
>> familiar IndexError and KeyError.
>>
>> Sorry, I'm not sure if I should send this sort of thing to
>> Python-Ideas or Python-Dev, so please let me know gently which one I
>> should (not) have sent it to.
>>
>> Best wishes
>> Rob Cliffe
>> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
>> 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/aurelien.campeas%40logilab.fr
>
>