Last active
December 12, 2015 02:39
-
-
Save gartenfeld/4700637 to your computer and use it in GitHub Desktop.
Processing multiple files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
# Command-line parsing supports filename*.txt | |
# Make a list of command line arguments, omitting the [0] element which is the script itself. | |
args = sys.argv[1:] | |
if not args: | |
print 'Some message.' | |
sys.exit(1) | |
for filename in args: | |
results = do_something(filename) | |
# Write output file | |
outf = open('output'+'name', 'w') | |
outf.write(results + '\n') | |
outf.close() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment