import argparse
parser = argparse.ArgumentParser(description='Demo')
parser.add_argument('--verbose',
action='store_true',
help='verbose flag' )
args = parser.parse_args()
if args.verbose:
print("~ Verbose!")
else:
print("~ Not so verbose")
I'm getting this error
usage: ipykernel_launcher.py [-h] [--verbose] ipykernel_launcher.py: error: unrecognized arguments: -f C:\Users\Sourav\AppData\Roaming\jupyter\runtime\kernel-c07f728a-968e-40af-b09e-e7d9b67b47fe.json
SystemExit: 2
C:\Users\Sourav\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py:2855: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D. warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
sys.argv
list that the parser sees includes this '-f'` argument, which it is not prepared to handle. – hpauljargparse
don't use anotebook
. Run it as an ordinary script from shell. If you want to set some value in a notebook, don't useargparse
. – hpaulj