next up previous contents index
Next: The break statement Up: Simple statements Previous: The return statement

The raise statement

  

raise_stmt:     "raise" condition ["," condition]

raise evaluates its first condition, which must yield a string, class, or instance object. If there is a second condition, this is evaluated, else None is substituted. If the first condition is a class object, then the second condition must be an instance of that class or one of its derivatives. If the first condition is an instance object, the second condition must be None.     

If the first object is a class or string, it then raises the exception identified by the first object, with the second one (or None) as its parameter. If the first object is an instance, it raises the exception identified by the class of the object, with the instance as its parameter.



guido@cwi.nl