Re: [Tutor] Command line args

2007-04-14 Thread Alan Gauld
"Teresa Stanton" <[EMAIL PROTECTED]> wrote > No one suggested this. That's great! Wish I had seen it sooner. > Thanks, > I'll put that in my notebook for further use later. Note that Fileinput is used to iterate over a (set of) file line by line, it doesn't read the entire file into a string

Re: [Tutor] Command line args

2007-04-13 Thread Teresa Stanton
No one suggested this. That's great! Wish I had seen it sooner. Thanks, I'll put that in my notebook for further use later. -Original Message- From: Daniel Yoo [mailto:[EMAIL PROTECTED] Sent: Friday, April 13, 2007 5:51 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Comm

Re: [Tutor] Command line args

2007-04-13 Thread Daniel Yoo
Hi Teresa, Has anyone on this thread already suggested the 'fileinput' module? From what I understand, what 'fileinput' does is exactly what you're asking from: http://mail.python.org/pipermail/tutor/2007-April/053669.html Here's documentation on 'fileinput': http://www.python.org/

Re: [Tutor] Command line args

2007-04-10 Thread Alan Gauld
"Kirk Bailey" <[EMAIL PROTECTED]> wrote > Try: > filename=sys.arv[1] > except Exception, e: This still doesn't help for the problem where a different exception is raised.It really does need to be try: filename = sys.argv[1]: except IndexError: > if filename='': > filename='fo

Re: [Tutor] Command line args

2007-04-09 Thread Kirk Bailey
ok, try this: Try: filename=sys.arv[1] except Exception, e: if filename='': filename='foo' # define a default value else: if foo: # detect one likely error foobarcode else:

Re: [Tutor] Command line args

2007-04-09 Thread Luke Paireepinart
Kirk Bailey wrote: > Teresa Stanton wrote: > >> If one argument to a script is provided I am to take the input from it. >> I figure that is presented like this: >> >> filename = sys.argv[1] >> > Try: > the 'try' keyword is not capitalized in Python. > filename=sys.arg[1] > except

Re: [Tutor] Command line args

2007-04-08 Thread Kirk Bailey
Teresa Stanton wrote: > If one argument to a script is provided I am to take the input from it. > I figure that is presented like this: > > filename = sys.argv[1] Try: filename=sys.arg[1] except exception, E: filename='FooBar' > data = open(filename).read() > > But, if none a

Re: [Tutor] Command line args

2007-04-07 Thread Andreas Kostyrka
* Teresa Stanton <[EMAIL PROTECTED]> [070407 18:52]: >If one argument to a script is provided I am to take the input from it. I >figure that is presented like this: > >filename = sys.argv[1] >data = open(filename).read() > >But, if none are provided, input should come from st

Re: [Tutor] Command line args

2007-04-07 Thread Alan Gauld
"Teresa Stanton" <[EMAIL PROTECTED]> 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

[Tutor] Command line args

2007-04-07 Thread Teresa Stanton
If one argument to a script is provided I am to take the input from it. I figure that is presented like this: filename = sys.argv[1] data = open(filename).read() But, if none are provided, input should come from standard input. How do I write that code? TY _