I have the following problem:
def main():
    try: 
        # DO some stuff here, load some class and execute it thats all
        processFile = cf.jsonLoad(opts.processFile);
        # load process module/class
        mod, ProcessClass = iH.importClassFromModule( **processFile["processClass"] )
        process = ProcessClass( processFile, jobGenModules = {"importHelpers":iH, "commonFunctions" : cf} )
        process.doProcessing()
    except Exception as e:
        print("====================================================================", file=sys.stderr)
        print("Exception occured here: " + str(e), file=sys.stderr)
        print("====================================================================", file=sys.stderr)
        traceback.print_exc(file=sys.stderr)
        return 1
if __name__ == "__main__":
   sys.exit(main());
when I launch the program from bash by redirecting stderr and stdout to the file by doing
yell() { echo "$0: $*" >&2; }
die() { yell "$*"; cleanup ; exit 111 ; }
try() { "$@" || die "cannot $*"; }
executeProg(){
    python3 main.py >> log.txt 2>&1
}
try executeProg
the stderr output of the exception above gets appended at the beginning of the file?
Is that general behavior of bash? Or am I doing something wrong in python? How can I make that the stderr is also appended at the position where the stdout is, meaning at the end of the file...?
 
     
     
    