B.G.R. wrote: > Hi all, [snip] > A little bit more complex, but that's the idea. That will work if the user > does something like "./myprog.py < code" or "cat code | ./myprog.py", and > that's ok, but if the user only does "./myprog.py" then I got to get into > interactive mode and show a prompt in every line expecting the user input > for that line. Problem is I don't know how to tell if I've been "piped" or > not. > I used to think that the piped program doesn't know anything and it's just > OS dependant to close and open the right descriptors, but I'm not sure > anymore. Any help or pointer in the right direction would be greatly > appreciated. > > Happy christmas everyone, > > RGB Hello RGB, what you are loking for is sys.stdin.isatty()
py> if sys.stdin.isatty(): ... print 'Console' ... else: ... print 'Redirected' Hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list