fptr = sys.stdout # stdout is already an open stream #or os.environ['OUTPUT_PATH'] = 'junk.txt' # before you open the fptr!
Here is what the above code is Doing:
1. It’s creating a file object called fptr.
2. It’s setting the file object to the standard output stream.
3. It’s setting the environment variable OUTPUT_PATH to the string junk.txt.
4. It’s opening the file object fptr in write mode.