Function wrapper in Python
Olav.Benum at bigfoot.com
Olav.Benum at bigfoot.com
Mon Oct 9 12:36:24 EDT 2000
I would like to write a function-wrapper that takes a
function and its arguments as arguments, redirect
output, and calls the function within a try/catch
block. Something like:
def function_wrapper( funcname, *name **unnamed):
try:
funcname( name, unnamed )#??
except OSError,error:
print "General exception"
if error:
print str(error)
def test_func( s ):
print s
function_wrapper( test_func , 'hello world')
(Ideally I would like something like having an abstract
base-class with the function name as an abstract method,
from this I would derive a class for my function, and
then call the init function like FucntionInstance(
Arguments)
Thanks!
Olav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20001009/2592ee01/attachment.html>
More information about the Python-list
mailing list