[PYTHON] I tried using argparse

Something that conveniently captures arguments.

Whether it's help, specifying argument types, default values, or even trying to design it yourself, the more convenient it is, the more complicated it is to use.

So, I relied on this area to investigate and use only the minimum rules.

-I'll write it somehow.

parser = argparse.ArgumentParser(description='Create Test data') #make parser
parser.add_argument('target', type=int, default=15, help='Specify the target length')
parser.add_argument('number', type=int, default=10, help='Specify the number of elements')
parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0') # version
args = parser.parse_args() #Interpret command line arguments

And the obtained value is

args.target
args.number

It seems that it can be taken out like.

Oh, convenient. It seems that you can specify it with various other options, but I don't need it now, so that's it.

end.

Recommended Posts

I tried using argparse
I tried using parameterized
I tried using mimesis
I tried using anytree
I tried using aiomysql
I tried using Summpy
I tried using coturn
I tried using Pipenv
I tried using matplotlib
I tried using "Anvil".
I tried using Hubot
I tried using ESPCN
I tried using openpyxl
I tried using Ipython
I tried using PyCaret
I tried using cron
I tried using ngrok
I tried using face_recognition
I tried using Jupyter
I tried using PyCaret
I tried using Heapq
I tried using doctest
I tried using folium
I tried using jinja2
I tried using folium
I tried using time-window
[I tried using Pythonista 3] Introduction
I tried using easydict (memo).
I tried face recognition using Face ++
I tried using Random Forest
I tried using BigQuery ML
I tried using Amazon Glacier
I tried using git inspector
[Python] I tried using OpenPose
I tried using magenta / TensorFlow
I tried using AWS Chalice
I tried using Slack emojinator
I tried using Rotrics Dex Arm # 2
I tried using Rotrics Dex Arm
I tried using GrabCut of OpenCV
I tried using Thonny (Python / IDE)
I tried server-client communication using tmux
I tried reinforcement learning using PyBrain
I tried deep learning using Theano
Somehow I tried using jupyter notebook
[Kaggle] I tried undersampling using imbalanced-learn
I tried shooting Kamehameha using OpenPose
I tried using the checkio API
[Python] I tried using YOLO v3
I tried asynchronous processing using asyncio
I tried scraping
I tried PyQ
I tried AutoKeras
I tried papermill
I tried django-slack
I tried Django
I tried spleeter
I tried cgo
I tried using Amazon SQS with django-celery
I tried using Azure Speech to Text.
I tried using Twitter api and Line api