[Tutor] input and output files from terminal

Brain Stormer brnstrmrs at gmail.com
Thu Apr 17 15:57:46 CEST 2008


Actually, Let me take that back with the raw_input comment since it is not
the idle issue but I didn't want to the program to be interactive so I
didn't want to wait for someone to put the information and press enter.
Thanks for the file direction method but how do I get the names of the files
so I can use it inside my program.

On Mon, Apr 14, 2008 at 2:57 PM, Alan Gauld <alan.gauld at btinternet.com>
wrote:

>
> "Brain Stormer" <brnstrmrs at gmail.com> wrote
>
> >I have a python program which works fine when run using idle but I
> >would
> > like call the program from the terminal.
> >
> > python test.py -i inputfile -o outputfile
>
> Easier to use file redirection:
>
> python test.py < inputfile > outputfile
>
> The -i flag in particular might conflict with Pythons own -i option.
>
> > I tried with raw_input but that only works in idle.
>
> What makes you think that?
> raw_input is the normal way to get input from stdin.
>
> Can you explain what you did and what the result was?
> Perhaps with a short code example?
>
> Try this for example:
>
> ####################
>
> name = raw_input('What's your name? ')
> print "hello", name
>
> ####################
>
> That can be run in IDLE or in a command window
> or using file redirection as described above.
>
> Tell us how you get on...
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080417/2ed872e6/attachment.htm 


More information about the Tutor mailing list