(self, filename, source=None)
Execute an existing file
Execute an existing file
Execute an existing file
def execfile(self, filename, source=None):
        "Execute an existing file"
        if source is None:
            with tokenize.open(filename) as fp:
                source = fp.read()
                if use_subprocess:
                    source = (f"__file__ = r'''{os.path.abspath(filename)}'''\n"
                              + source + "\ndel __file__")
        try:
            code = compile(source, filename, "exec")
        except (OverflowError, SyntaxError):
            self.tkconsole.resetoutput()
            print('*** Error in script or command!\n'
                 'Traceback (most recent call last):',
                  file=self.tkconsole.stderr)
            InteractiveInterpreter.showsyntaxerror(self, filename)
            self.tkconsole.showprompt()
        else:
            self.runcode(code)
def execfile ( self , filename , source = None ) : if source is None : with tokenize . open ( filename ) as fp : source = fp . read ( ) if use_subprocess : source = ( f"__file__ = r'''{os.path.abspath(filename)}'''\n" + source + "\ndel __file__" ) try : code = compile ( source , filename , "exec" ) except ( OverflowError , SyntaxError ) : self . tkconsole . resetoutput ( ) print ( '*** Error in script or command!\n' 'Traceback (most recent call last):' , file = self . tkconsole . stderr ) InteractiveInterpreter . showsyntaxerror ( self , filename ) self . tkconsole . showprompt ( ) else : self . runcode ( code )