Skip to content

Instantly share code, notes, and snippets.

View transistor1's full-sized avatar

Steve Russo transistor1

View GitHub Profile
@transistor1
transistor1 / redirect.py
Last active September 24, 2022 22:24 — forked from natedileas/redirect.py
c-level stdout redirection on windows
""" Tested on Windows 10, 64 bit, Python 3.6
Sources:
https://eli.thegreenplace.net/2015/redirecting-all-kinds-of-stdout-in-python/
https://stackoverflow.com/questions/17942874/stdout-redirection-with-ctypes
Adapted as multiplatform c-redirect
"""
from contextlib import contextmanager