This happens, because you don't catch any exception while calling
You can catch all exceptions and log them to a file.
Instead of overwriting sys.stdout, use the print function.
You can define with
func()
.You can catch all exceptions and log them to a file.
Instead of overwriting sys.stdout, use the print function.
You can define with
file
the outputfile which is print using.def decorator(func): def wrapper(): with open('output', 'w') as fd: try: result = func() except Exception as error: print(error, file=fd) else: print(result, file=fd) return wrapperTo return a value, you have to add after the print in the else block
return result
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!