En Fri, 27 Jul 2007 19:49:17 -0300, Neal Becker <[EMAIL PROTECTED]>
escribió:
> import exceptions
>
> class nothing (exceptions.Exception):
> def __init__ (self, args=None):
> self.args = args
>
> if __name__ == "__main__":
> raise nothing
>
> Traceback (most recent call last):
>
Neal Becker <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]:
> Alex Popescu wrote:
>
>> Neal Becker <[EMAIL PROTECTED]> wrote in
>> news:[EMAIL PROTECTED]:
>>
>
> [snip...]
>
>>>
>>
>> You can pass to the exception:
>> a) a string (it will become the message)
>> b) a tuple of values (can
Neal Becker <[EMAIL PROTECTED]> writes:
> should set self.args to None. Nothing wrong there, and what has this got to
> do with NoneType being iterable?
Probably the traceback constructor tried to iterate through the args.
You should initialize the args to an empty tuple, not None. Also
note th
Alex Popescu wrote:
> Neal Becker <[EMAIL PROTECTED]> wrote in
> news:[EMAIL PROTECTED]:
>
>> import exceptions
>>
>> class nothing (exceptions.Exception):
>> def __init__ (self, args=None):
>> self.args = args
>>
>> if __name__ == "__main__":
>> raise nothing
>>
>> Traceback (
Neal Becker <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]:
> import exceptions
>
> class nothing (exceptions.Exception):
> def __init__ (self, args=None):
> self.args = args
>
> if __name__ == "__main__":
> raise nothing
>
> Traceback (most recent call last):
> File "",
Neal Becker <[EMAIL PROTECTED]> writes:
> TypeError: 'NoneType' object is not iterable
> I'll have to say, I don't understand this error.
It's "lame duck typing". The .args attribute on an Exception instance
is expected to be a tuple of the arguments passed through the raise
statement. It is Non