When playing with sys.stdin.read()(Terminal, Mac OS Sierra), strange behavior is detected when it becomes unusable. What's happening?
import sys
sys.stdin.read()
sys.stdin.read()
sys.stdin.read()
sys.stdin.read()
Note: ctrl+ d= EOF on Mac, ctrl+ zon Windows
Update: I noticed the same behavior for any line of length 5 with one new line ... shorter / longer lines or more / fewer new lines behave correctly ...
import sys
sys.stdin.read()
12345
'12345'
sys.stdin.read()
1234
'1234\n'
sys.stdin.read()
12345
'12345\n\n'
sys.stdin.read()
12345
'12345\n'
sys.stdin.read()
''
I would like to understand what causes this behavior when I use it in a program. I will definitely check it in the code, but still I would like to understand how to avoid these two cases when it does not work.