how to use bool

jimgardener at gmail.com jimgardener at gmail.com
Thu Jan 3 16:49:19 CET 2008


hi, i have some code where i set a bool type variable and if the value
is false i would like to return from the method with an error msg..
being a beginner I wd like some help here

class myclass:
     .........
    def  mymethod(self):
             success=True
             msg="all validation OK"
             success=validateSthing()
             if(success==False):
                   msg="sthing failed"
                   return (success,msg)

             dosomeprocessing()
             .....
             success=validateSthingelse()
             if(success==False):
                   msg="sthingelse  failed"
                   return (success,msg)
             domoreprocessing()
              ....
               return(success,msg)

i would like to know if this way of doing this is OK..I have need of
many kinds of validations in this ..is there a better way of doing
this ?

thank you




More information about the Python-list mailing list