I know linux solutions of opening a /dev/null and redirecting stout to it.
(like Prevent subprocess of subprocess from writing to stdout or similar ones)
What is the solution in windows?
Asked
Active
Viewed 3,820 times
4
1 Answers
11
Use the same approach, but use os.devnull
which is the portable solution. On Windows this will send the output to NUL
.
In fact, this solution is already recommended in the question you linked to:
with open(os.devnull, 'w') as tempf:
proc = Popen(cmd, stdout=tempf, stderr=tempf)
proc.communicate()

Community
- 1
- 1

Andrew Clark
- 202,379
- 35
- 273
- 306