Function wrapper in Python

olavb at my-deja.com olavb at my-deja.com
Wed Oct 25 10:56:32 EDT 2000


In article <8runes02q1 at news2.newsguy.com>,
  "Alex Martelli" <aleaxit at yahoo.com> wrote:
> <Olav.Benum at bigfoot.com> wrote in message
> Maybe if you post a complete, short example of code where
> you would like to USE the desired construct, as you did
> for the function-wrapping-function case, we could help...
>

In C++/Python/Delphi inspired pseudo-code

class Wrapper:
    abstract wrapped_function()
    call_func(*positional, **keyword):
        try:
            apply( wrapped_function, positional. keyword)
        except OSError, error:
            log_exception( "Fatal general exception", error )
            if error:
                print str(error)
                print "General exceptiom, see logs"
    Wrapper((*positional, **keyword):#constructor
            #construct object
            call_func( positional, keyword )

class Wrapp_set_opt( Wrapper):
    wrapped_function( dir, level ):
        set_opt( dir, level )

Wrapp_set_opt( dir, level)


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list