Reputation: 101
When I try to use argparse.parseargs()
by printing it (for example), it always returns Namespace(argName='String Content')
So, if I get returned that I can't use it for other functions, for working with path (in my case).
So, there is a way to only get returned just the string being raw (for working with Windows paths, in my case)?
Upvotes: 0
Views: 265
Reputation: 532303
parse_args()
returns a collection of values, (roughly) one for each argument you define. That doesn't change just because you only define one argument. Just extract the value you want.
p = ArgumentParser()
p.add_argument('--argName', default="foo")
args = p.parse_args()
print(args.argName)
Upvotes: 1