is parameter an iterable?
Fredrik Lundh
fredrik at pythonware.com
Wed Nov 16 11:39:57 EST 2005
Rick Wotnaz wrote.
> ... which leads me to belive that 'msg' is not type(str). It can be
> coerced (str(msg).find works as expected). But what exactly is msg?
> It appears to be of <type 'instance'>, and does not test equal to a
> string.
it's an instance of the exception type, of course.
:::
if you do
raise SomeError, value
Python will actually do
raise SomeError(value)
(that is, create a SomeError exception and pass the value as its
first argument).
you can use either form in your code (I prefer the latter myself).
:::
as for catching the exceptions, if you do
try:
...
except SomeError, v:
...
Python will treat this as
try:
...
except:
# some exception occurred
typ = sys.exc_type
exc = sys.exc_value
if issubclass(typ, SomeError):
v = exc
...
else:
raise # propagate!
(where typ and exc are internal variables)
</F>
More information about the Python-list
mailing list