Charles Yeomans
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
> 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
http://svn.python.org/view/python/trunk/Objects/exceptions.c?revision=77045&view=markup
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Gerald Britton
> 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