Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exception class documentation

2 views
Skip to first unread message

Charles Yeomans

unread,
Feb 5, 2010, 12:55:58 PM2/5/10
to Python
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?


Charles Yeomans

Gerald Britton

unread,
Feb 5, 2010, 2:13:36 PM2/5/10
to Charles Yeomans, Python
> --
> http://mail.python.org/mailman/listinfo/python-list
>

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,),)

--
Gerald Britton

Charles Yeomans

unread,
Feb 5, 2010, 7:27:55 PM2/5/10
to Python

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

> On Fri, Feb 5, 2010 at 12:55 PM, Charles Yeomans <cha...@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


Gerald Britton

unread,
Feb 6, 2010, 8:09:10 AM2/6/10
to Charles Yeomans, Python
If you browse the Python source tree, you should be able to find it.

http://svn.python.org/view/python/trunk/Objects/exceptions.c?revision=77045&view=markup

> --
> http://mail.python.org/mailman/listinfo/python-list
>

--
Gerald Britton

Charles Yeomans

unread,
Feb 6, 2010, 11:05:42 AM2/6/10
to Gerald Britton, Python

On Feb 6, 2010, at 8:09 AM, Gerald Britton wrote:

> If you browse the Python source tree, you should be able to find it.
>
> http://svn.python.org/view/python/trunk/Objects/exceptions.c?revision=77045&view=markup
>


Perfect (even if I have to read C). Thanks.

Charles Yeomans

0 new messages