Filename on the command line
examples/files/single.py
import sys def main(): if len(sys.argv) != 2: exit(f"Usage: {sys.argv[0]} FILENAME") filename = sys.argv[1] with open(filename) as fh: print("Working on the file", filename) main()
$ python single.py Usage: single.py FILENAME $ python single.py numbers.txt Working on the file numbers.txt