io-redirection

Is there a way to find out the name of the file stdout is redirected to in Python

Is there a way to find out the name of the file stdout is redirected to in Python Question: I know how to detect if my Python script’s stdout is being redirected (>) using sys.stdout.isatty() but is there a way to discover what it’s being redirected to? For example: python my.py > somefile.txt Is there …

Total answers: 2