Python Forum
is it safe to close stdin - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: is it safe to close stdin (/thread-17262.html)



is it safe to close stdin - Skaperen - Apr-04-2019

in a program that usually opens, reads and closes files, it sometimes reads stdin. it will only read it to EOF once. is it then safe to close it? if so, then i can omit the test to see if it is stdin. i know it's a cost one way or the other, but a small one. but the test just looks silly.


RE: is it safe to close stdin - Gribouillis - Apr-04-2019

I've never heard that closing stdin would be unsafe, so do it!