MCPcopy Index your code
hub / github.com/python/cpython / _prog_name

Function _prog_name

Lib/argparse.py:1897–1916  ·  view source on GitHub ↗
(prog=None)

Source from the content-addressed store, hash-verified

1895 raise ValueError('mutually exclusive groups cannot be nested')
1896
1897def _prog_name(prog=None):
1898 if prog is not None:
1899 return prog
1900 arg0 = _sys.argv[0]
1901 try:
1902 modspec = _sys.modules['__main__'].__spec__
1903 except (KeyError, AttributeError):
1904 # possibly PYTHONSTARTUP or -X presite or other weird edge case
1905 # no good answer here, so fall back to the default
1906 modspec = None
1907 if modspec is None:
1908 # simple script
1909 return _os.path.basename(arg0)
1910 py = _os.path.basename(_sys.executable)
1911 if modspec.name != '__main__':
1912 # imported module or package
1913 modname = modspec.name.removesuffix('.__main__')
1914 return f'{py} -m {modname}'
1915 # directory or ZIP file
1916 return f'{py} {arg0}'
1917
1918
1919class ArgumentParser(_AttributeHolder, _ActionsContainer):

Callers 1

__init__Method · 0.85

Calls 2

basenameMethod · 0.45
removesuffixMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…