Correct behavior for failure during __init__()

Jeff Putsch putsch at fiber.mxim.com
Wed May 16 18:47:46 EDT 2001


Howdy,

I'm wrapping a C library with with python and swig. I'm defining a class
like this (wLib) is the wrapped C library:

   import wLib

   class ddId:
       def __init__(self, arg1, arg2):
           t1 = wLib.createObj(arg1, arg2)
           if t1:
               self.Id = t1
           else:
               NOW WHAT?

It is possible that the call to wLib.createObj does not succeed. In this
case it is not clear to me what I should do where I've marked "NOW WHAT?"
in the code above.

Any suggestions and/or pointers will be greatly appreciated.

Thanks,

Jeff.




More information about the Python-list mailing list