(self, stmt="pass", setup="pass", timer=default_timer,
                 globals=None)
Constructor.  See class doc string.
Constructor.  See class doc string.
Constructor . See class doc string .
def __init__(self, stmt="pass", setup="pass", timer=default_timer,
                 globals=None):
        """Constructor.  See class doc string."""
        self.timer = timer
        local_ns = {}
        global_ns = _globals() if globals is None else globals
        init = ''
        if isinstance(setup, str):
            # Check that the code can be compiled outside a function
            compile(setup, dummy_src_name, "exec")
            stmtprefix = setup + '\n'
            setup = reindent(setup, 4)
        elif callable(setup):
            local_ns['_setup'] = setup
            init += ', _setup=_setup'
            stmtprefix = ''
            setup = '_setup()'
        else:
            raise ValueError("setup is neither a string nor callable")
        if isinstance(stmt, str):
            # Check that the code can be compiled outside a function
            compile(stmtprefix + stmt, dummy_src_name, "exec")
            stmt = reindent(stmt, 8)
        elif callable(stmt):
            local_ns['_stmt'] = stmt
            init += ', _stmt=_stmt'
            stmt = '_stmt()'
        else:
            raise ValueError("stmt is neither a string nor callable")
        src = template.format(stmt=stmt, setup=setup, init=init)
        self.src = src  # Save for traceback display
        code = compile(src, dummy_src_name, "exec")
        exec(code, global_ns, local_ns)
        self.inner = local_ns["inner"]
def __init__ ( self , stmt = "pass" , setup = "pass" , timer = default_timer , globals = None ) : self . timer = timer local_ns = { } global_ns = _globals ( ) if globals is None else globals init = '' if isinstance ( setup , str ) : # Check that the code can be compiled outside a function compile ( setup , dummy_src_name , "exec" ) stmtprefix = setup + '\n' setup = reindent ( setup , 4 ) elif callable ( setup ) : local_ns [ '_setup' ] = setup init += ', _setup=_setup' stmtprefix = '' setup = '_setup()' else : raise ValueError ( "setup is neither a string nor callable" ) if isinstance ( stmt , str ) : # Check that the code can be compiled outside a function compile ( stmtprefix + stmt , dummy_src_name , "exec" ) stmt = reindent ( stmt , 8 ) elif callable ( stmt ) : local_ns [ '_stmt' ] = stmt init += ', _stmt=_stmt' stmt = '_stmt()' else : raise ValueError ( "stmt is neither a string nor callable" ) src = template . format ( stmt = stmt , setup = setup , init = init ) self . src = src # Save for traceback display code = compile ( src , dummy_src_name , "exec" ) exec ( code , global_ns , local_ns ) self . inner = local_ns [ "inner" ]