Weird exception in my, um, exception class constructor
Joel Koltner
zapwireDASHgroups at yahoo.com
Tue May 27 16:21:52 EDT 2008
I have a generic (do nothing) exception class that's coded like this:
class MyError(exceptions.Exception):
def __init__(self,args=None):
self.args = args
When I attempt to raise this exception via 'raise MyError' I get an exception
within the MyError constructor __init__ as follows:
Traceback (most recent call last):
[lines deleted]
File "c:\Documents and Settings\Joel.Kolstad\My Documents\Python\
MyStuff.py", line 7, in __init__
self.args = args
TypeError: 'NoneType' object is not iterable
Ummm... why should 'args' have to be iterable anyway? I don't understand
what's going on here? Could someone help me with this?
I've found empirically that I can write:
if args self.args = args
...and everything *appears* to work OK, but I'd really like to know what the
core problem is.
Thank you,
---Joel
More information about the Python-list
mailing list