Python Forum

Full Version: is it safe to close stdin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
I've never heard that closing stdin would be unsafe, so do it!