"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
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
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/
"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
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:
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
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
* 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
"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
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
_
10 matches
Mail list logo