mam taki skrypt:Jak iteracyjne nad argumentów
import argparse
parser = argparse.ArgumentParser(
description='Text file conversion.'
)
parser.add_argument("inputfile", help="file to process", type=str)
parser.add_argument("-o", "--out", default="output.txt",
help="output name")
parser.add_argument("-t", "--type", default="detailed",
help="Type of processing")
args = parser.parse_args()
for arg in args:
print(arg)
Ale nie robi praca. Otrzymuję komunikat o błędzie:
TypeError: 'Namespace' object is not iterable
Jak powtórzyć argumenty i ich wartość?
typowym zastosowaniem jest implementacja trybu 'debug-input', w którym skrypt wypisuje wszystkie argumenty wejściowe i kończy działanie; przydatne dla takich rzeczy jak upewnienie się, że wartości wejściowe datetime zostały poprawnie zinterpretowane –