[Tutor] Command line args
Alan Gauld
alan.gauld at btinternet.com
Sat Apr 7 19:47:30 CEST 2007
"Teresa Stanton" <tms43 at clearwire.net> wrote
> If one argument to a script is provided I am to take the input from
> it.
OK This sounds like a homework so I can't give you a direct
answer but only some things to consider.
> I figure that is presented like this:
>
> filename = sys.argv[1]
> data = open(filename).read()
So far so good but how will you know whether there is
anyting in sys.argv to read?
> But, if none are provided, input should come from standard input.
Standard input is where you normally get input in interactive
programs.
How do you normally get a user to giove you information?
You'll find more about receiving input from users in the
"Talking to the User" topic of my tutorial.
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list