Operating environment
Xeon E5-2620 v4 (8 cores) x 2
32GB RAM
CentOS 6.8 (64bit)
openmpi-1.8.x86_64 and its-devel
mpich.x86_64 3.1-5.el6 and its-devel
gcc version 4.4.7 (And gfortran)
NCAR Command Language Version 6.3.0
WRF v3.7.Use 1.
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
Python 3.6.0 on virtualenv
When executing a Python script, check if -d
is attached.
Reference: https://docs.python.jp/3/howto/argparse.html
The part described in store_true
.
test_python_170324a.py
import argparse
parser = argparse.ArgumentParser(description="do something")
parser.add_argument(
'-d',
'--debugMode',
dest='debugMode',
action='store_true',
help='debug mode')
cmd_args = parser.parse_args()
if(cmd_args.debugMode == False):
print("normal mode")
else:
print("debug mode")
result
$ python test_python_170324a.py
normal mode
$ python test_python_170324a.py -d
debug mode
$ python test_python_170324a.py --debugMode
debug mode
Recommended Posts