Feb 24 Lecture - 1 best2.py square6 Today we will take a...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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[0] is the script name square6 sys.argv[1] would be the first item after the...
View Full Document

Page1 / 6

Feb 24 Lecture - 1 best2.py square6 Today we will take a...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online