On 10/23/2013 05:20 PM, Ben Finney wrote:
random...@fastmail.us writes:
On Wed, Oct 23, 2013, at 16:52, Chris Angelico wrote:
There are times when this is correct behaviour - like asking for
passwords (SSH and sudo work like this).
Less (or pagers generally, or an interactive text editor that allows
creating a file from standard input) would be another example of a
program where it makes sense to do this.
You're both describing programs that read the console, which is not what
the OP was asking for. The OP was asking about re-opening stdin after
reaching EOF, which is incoherent as far as I understand it.
I'm still waiting for the OP to clarify what they want to do.
'Easy there Rainman, the question is entirely coherent,
though it may not be achievable this way. The goal of the
exercise was:
- Read a file the user specifies via command line redirection
- When the file is fully read, return to reading keyboard
input with things like raw_input and get_pass which I believe
use stdin as a source ... probably to avoid having to manually
cope with ttys and ptys themselves. One of those two functions -
I don't recall which - was giving me a problem with stdin redirected.
In the end, I broke down and added a command line parameter to
specify which file to read in so that stdin would be unaffected.
Now that I think about it, as I recall from the prehistoric era of writing
lots of assembler and C, if you use shell redirection, stdin shows
up as a handle to the file and there is no way to retrieve/reset it
its default association with the tty/pty. Since python is layered on
top of this, I expect the same would be the case here as well.
--
----------------------------------------------------------------------------
Tim Daneliuk tun...@tundraware.com
PGP Key: http://www.tundraware.com/PGP/
--
https://mail.python.org/mailman/listinfo/python-list