Parameter parsen

https://docs.python.org/3/library/argparse.html#module-argparse

Drei Optionen stehen zur Verfügung:

Spezialmodule:

import sys
print('Zahl der Argumente: {}'.format(len(sys.argv)))
Zahl der Argumente: 3
sys.argv
['/Users/peter/pyhasse/src/lib/python3.7/site-packages/ipykernel_launcher.py',
 '-f',
 '/Users/peter/Library/Jupyter/runtime/kernel-fc4db678-7851-42a9-aa62-e46a77c32ded.json']

getopt

is deprecated and will not be developed further;

Argparse

"""import argparse

parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs='+',
                    help='an integer for the accumulator')
parser.add_argument('--sum', dest='accumulate', action='store_const',
                    const=sum, default=max,
                    help='sum the integers (default: find the max)')

args = parser.parse_args()
print(args.accumulate(args.integers))

"""