What is a namespace object?
The documentation for argparse.Namespace can be found here. You can access the s attribute by doing args.s. If you’d like to access this as a dictionary, you can do vars(args), which means you can also do vars(args)[‘s’]
The documentation for argparse.Namespace can be found here. You can access the s attribute by doing args.s. If you’d like to access this as a dictionary, you can do vars(args), which means you can also do vars(args)[‘s’]
args.infile is a list of filenames, not one filename. Loop over it: Here I used os.path.splitext() to split extension and base filename so you can generate a new output filename adding 1 to the base.
I think a more canonical way to do this is via: and argparse supports this version nicely: Of course, if you really want the –arg <True|False> version, you could pass ast.literal_eval as the “type”, or a user defined function …