Exception class documentation

Charles Yeomans charles at declaresub.com
Fri Feb 5 19:27:55 EST 2010


On Feb 5, 2010, at 2:13 PM, Gerald Britton wrote:

> On Fri, Feb 5, 2010 at 12:55 PM, Charles Yeomans <charles at declaresub.com 
> > wrote:
>> I am so far unable to find the information I want about the  
>> Exception class.
>>  Information like the signature of __init__ seems to be  
>> unavailable.  Any
>> suggestions where I might find such information?
>>
>
> Though not documented, some silly tests indicate that it will accept
> pretty much anything:
>
>>>> Exception(1,2,4,54)
> Exception(1, 2, 4, 54)
>>>> Exception(*range(10))
> Exception(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
>>>> Exception(*range(50))
> Exception(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
> 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
> 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49)
>>>> Exception('a','b','c','d','e')
> Exception('a', 'b', 'c', 'd', 'e')
>>>> Exception(Exception(1))
> Exception(Exception(1,),)

I had also tried such tests.  If you pass a single argument msg, it is  
assigned to the message property, and the args property is set to  
(msg,). If you pass more than one argument, the tuple of arguments is  
assigned to the args property, and nothing is assigned to the message  
property.  I was hoping to at least find source code that provides a  
definitive answer.


Charles Yeomans





More information about the Python-list mailing list