python – What is a namespace object?
python – What is a namespace object?
- The documentation for
argparse.Namespace
can be found here. - You can access the
s
attribute by doingargs.s
. - If youd like to access this as a dictionary, you can do
vars(args)
, which means you can also dovars(args)[s]
It is the result object that argparse
returns; the items named are attributes:
print(args.s)
This is a very simple object, deliberately so. Your parsed arguments are attributes on this object (with the name determined by the long option, or if set, the dest
argument).
python – What is a namespace object?
you can access as args.s
, NameSpace class is deliberately simple, just an object subclass with a readable string representation. If you prefer to have dict-like view of the attributes, you can use the standard Python idiom, vars(). Source