how to use bool

jimgardener at gmail.com jimgardener at gmail.com
Sun Jan 6 11:56:14 EST 2008



some more doubts in this area,,forgive the ignorance of a beginner

i have

class MyError(Exception):
   def __init__(self,msg)
        self.msg=msg

now my method that can raise  this is

class SomeClass:
 ...........
   def mymethod(self):
      if (somecondition):
         raise MyError("somecondn failed")

if another method in the same class calls this method but wants to
pass the error to a gui code which calls it,,can i do like this

  def callingmethode(self):
      try:
         mymethod()
      except MyError,myerr:
         raise myerr

so that I can handle the error in a gui code that calls
callingmethode()

class MyGUI:
   def guimethode(self):
      someinst=SomeClass()
      try:
        someinst.callingmethode()
      except MyError,myer:
         self.dealwithMyError(myer)

is this kind of raising exception the correct way?I am getting syntax
error at
except MyError,myerr:
         raise myerr




More information about the Python-list mailing list