def error(e):
if isinstance(e, ValueError):
print "something wrong"
# what do we do with other errors?
def loggedIn(r, protocol):
protocol.isonline("joe", gotResult, error)
def gotResult(r):
if r:
print "joe is online"
def check(protocol):
f = lambda r: loggedIn(r, protocol)
protocol.login("itamar", f, error)