redirecting sys.stdout, AttributeError

Hi All

I’m trying to redirect my sys.stdout to a file (i have done this before in other python scripts).
Below my code:

sys.stdout = open("console_log.txt", "w")	# <<== Error occurs here

	... otehr  code ...

sys.stdout = sys.__stdout__

The error i am getting is the folowing:

AttributeError: ‘module’ object has no attribute ‘stdout’

However if i check the openMV Doc i find that stdout should exist.

any help would be greatly appreciated

That’s a cool use case. I don’t know if that actually works in MicroPython. All of our print and exceptions are send through the MP_HAL (except a few printfs() here and there)… so, technically this should be possible.

I think this is more of a general question for MicroPython.

Probably not possible.