Command line arguments

suggest change
if len(sys.argv) != 4:         # The script name needs to be accounted for as well.
    raise RuntimeError("expected 3 command line arguments")

f = open(sys.argv[1], 'rb')    # Use first command line argument.
start_line = int(sys.argv[2])  # All arguments come as strings, so need to be
end_line = int(sys.argv[3])    # converted explicitly if other types are required.

Note that in larger and more polished programs you would use modules such as click to handle command line arguments instead of doing it yourself.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents