Исключения


class General1(Exception): pass
class General2(StandardError): pass

try:
    some_action()
    raise General, "Error in code"
    #raise string
    #raise string, data
    #raise instance
    #raise class, instance
except Exception:
    print "Exception"
    raise  # Повтор исключения
except (General1, General2):
    print sys.exc_info()
except General, e:
    print "Exception: ", e
except:
    print "Other error"
else:
    all_ok()
finally:
    closea_ll()

# Проверки assert

def f(x,y)
    assert x>y
    return x*y