This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 1 best2.py square6 Today we will take a working best.py and enhance it square6 Enhancements will include: boxshadowdwn Accepting input either interactively or from the command line boxshadowdwn Checking to make sure the input file really exists boxshadowdwn Checking if the output file already exists square6 If no, then make a new one square6 If yes, then append the result to the existing file New Programming Statements square6 We know how to make Python interactively ask us for information, using input and raw_input square6 How do we make a program look for input from the command line at time of execution? square6 best2.py simped.out best.out square6 We can use the argv variable, part of the sys module 2 sys.argv square6 First, will need to import sys square6 argv is the list of command line arguments passed to the to the script square6 Since it is a list, we can access the individual items through the index square6 sys.argv is the script name square6 sys.argv would be the first item after the...
View Full Document
- Spring '11
- error handling