Reputation: 10970
I for the life of me can not remember how to test for the instination of a python class.
It was something like:
try:
m = MyModel()
except:
...
I can't remember the exception to call or the assert to use.
Upvotes: 3
Views: 824
Reputation: 12570
There is no common exception to use for failed instantiation. The constructor (both __init__
and __new__
) can raise any exception it wants. The except
statement you have without an explicit exception will catch every type of exception, which may be what you want.
Upvotes: 1
Reputation: 64137
I'm not exactly sure what you are asking, however here is a list of all built in exceptions for Python (2.7):
http://docs.python.org/library/exceptions.html
Hope this helps.
Upvotes: 0