Re: is parameter an iterable?



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>



.



Relevant Pages

  • Re: is parameter an iterable?
    ... > it's an instance of the exception type, ... create a SomeError exception and pass the value as its ... > Python will treat this as ... code sample, I'm not the only one who was mistaken about the nature ...
    (comp.lang.python)
  • Pure Python GUI lib?
    ... I don't like to update the module for different python and the module ... then it crashes with this msg: ... WindowsError: exception: access violation writing 0x72292AA4 ...
    (comp.lang.python)
  • Re: class-wide begin/end blocks/exception handling
    ... class HiThere ...  rescue Exception => msg ...   self.exceptionHandle ...
    (comp.lang.ruby)
  • Re: Stop excution (aka silent exception)
    ... Without going into a diatribe here, global exception handling should have ... To display a friendly msg to the user before exiting (or restart the app ... excution of the calling method as well, as does an exception that stops ...
    (microsoft.public.dotnet.framework.compactframework)
  • GDI+ Exception
    ... We have experienced following exception in our application that runs ... I had gone through the internet to find an answer about ... at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg) ... wparam, IntPtr lparam) ...
    (microsoft.public.dotnet.languages.csharp)