I am using argparse
to parse command line arguments. While going through the documentation for argparse
I could only see a provision to use a different program name.
I want to be able to use the default program name without having to import sys
. There is nothing in argparse
, as far as I can see, that will return the program name.
import argparse
parser = argparse.ArgumentParser()
args = parser.parse_args()
print(dir(args))
And here's the output:
['__class__', '__contains__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_get_args', '_get_kwargs']
Is there any other way of retrieving the program name without having to import the sys
module?