Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57400
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Subject | Re: Reading From stdin After Command Line Redirection |
| Date | 2013-10-24 14:53 +1100 |
| References | (1 earlier) <7wli1jemvg.fsf@benfinney.id.au> <CAPTjJmr6VnTvc0rdPmadp5D39igweUAB1jZG_SgLO4qT9ak0Ug@mail.gmail.com> <1382562096.2967.37713425.4901765B@webmail.messagingengine.com> <mailman.1431.1382566824.18130.python-list@python.org> <52686540.6000401@tundraware.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1436.1382586805.18130.python-list@python.org> (permalink) |
Tim Daneliuk <tundra@tundraware.com> writes: > 'Easy there Rainman I'll thank you not to use mental deficiency as some kind of insult. Calling someone “Rainman” is to use autistic people as the punchline of a joke. We're a community that doesn't welcome such ableist slurs. > 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. Thank you for clarifying. I think the request is incoherent: If you want to allow the user to primarily interact with the program, this is incompatible with also wanting to redirect standard input. Rather, you should add to your program an option to allow specifying a file to read, and present usage examples that don't redirect standard input. > 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. That's the right solution, I'd say. > 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. Right. Congratulations for learning more about the design of the OS and making a program that fits in well :-) -- \ “A lot of people are afraid of heights. Not me, I'm afraid of | `\ widths.” —Steven Wright | _o__) | Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-23 12:25 -0500
Re: Reading From stdin After Command Line Redirection Chris Angelico <rosuav@gmail.com> - 2013-10-24 07:40 +1100
Re: Reading From stdin After Command Line Redirection Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 07:46 +1100
Re: Reading From stdin After Command Line Redirection Chris Angelico <rosuav@gmail.com> - 2013-10-24 07:52 +1100
Re: Reading From stdin After Command Line Redirection random832@fastmail.us - 2013-10-23 17:01 -0400
Re: Reading From stdin After Command Line Redirection Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 09:20 +1100
Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-23 19:09 -0500
Re: Reading From stdin After Command Line Redirection Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 14:53 +1100
Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-23 23:36 -0500
Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-23 23:39 -0500
Re: Reading From stdin After Command Line Redirection Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 15:54 +1100
Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-24 06:58 -0500
Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-24 06:58 -0500
Re: Reading From stdin After Command Line Redirection Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-24 13:10 +0100
Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-24 08:41 -0500
Re: Reading From stdin After Command Line Redirection feedthetroll@gmx.de - 2013-10-24 07:36 -0700
Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-24 09:43 -0500
Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-24 08:41 -0500
Re: Reading From stdin After Command Line Redirection Ethan Furman <ethan@stoneleaf.us> - 2013-10-24 07:30 -0700
Re: Reading From stdin After Command Line Redirection Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-24 09:14 +0100
Re: Reading From stdin After Command Line Redirection Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 19:43 +1100
Re: Reading From stdin After Command Line Redirection Tim Chase <python.list@tim.thechases.com> - 2013-10-24 05:45 -0500
Re: Reading From stdin After Command Line Redirection Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-24 12:33 +0100
Re: Reading From stdin After Command Line Redirection Ethan Furman <ethan@stoneleaf.us> - 2013-10-24 07:39 -0700
Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-23 19:09 -0500
Re: Reading From stdin After Command Line Redirection Chris Angelico <rosuav@gmail.com> - 2013-10-24 09:23 +1100
csiph-web