HowCanI: inlined exceptions

ben at co.and.co ben at co.and.co
Sat May 27 14:03:36 CEST 2000


 
def foo(str):
    return str

def baz(str):
    raise str

def bar(str1,str2):
    return str1 + str2

def catch(function, list_of_argcs, error=None):
    try:
        return apply(function, list_of_argcs)
    except:
        return error
        

a = catch(foo, ("blabla",), "Failed")
print a
b = catch(baz, ("blabla",))
print b
c = catch(bar, ("blabla", "flafla"))
print c

Greetings,
-- 
ben . de . rydt at pandora . be ------------------ your comments
http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora




More information about the Python-list mailing list