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 exception, E:
>
you should only catch the exception you expect, so you don't
accidentally silence an unrelated error.
so
except IndexError:
because you're trying to index into a list that might not have 2 or more
elements.
> filename='FooBar'
>
You said you wanted the input from standard input, so just put a
raw_input here.
so the new code is:
try: filename = sys.argv[1]
except IndexError: filename = raw_input("Prompt: ")
HTH,
-Luke
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor