Given the following python script….
$ cat readStdin.py
#!/usr/bin/python
import sys
var = "".join(sys.stdin.readlines()).rstrip()
print var
… I get the follwing output:
$ echo hello | python -i readStdin.py
hello
>>>
$
… in other words it does not hang in the python console, but goes back to bash. Does anyone out there know how to make it stay in the python console???
Consider this –
Echo produces
print 4*2. Python even in interactive mode, considers this as input to be interpreted. Hence we see the 8 there. After this, the interpreter encounters anEOF, so it quits. Consider what you press to quit the interpreter –Ctrl+dor^D. This is just another way to produceEOFon *nix.