Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

add option in python script

from optparse import OptionParser
...
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
                  help="write report to FILE", metavar="FILE")
parser.add_option("-q", "--quiet",
                  action="store_false", dest="verbose", default=True,
                  help="don't print status messages to stdout")

(options, args) = parser.parse_args()
Comment

add option in python script


import argparse
import sys

parser = argparse.ArgumentParser(description="Does some awesome things.")
parser.add_argument('message', type=str, help="pass a message into the script")

if __name__ == '__main__':
    args = parser.parse_args(sys.argv[1:])
    print args.message

Comment

PREVIOUS NEXT
Code Example
Python :: line plotly with shaded area 
Python :: run a python script from another python script on a raspberry pi 
Python :: python set timezone windows 
Python :: input two numbers in python in a single line 
Python :: how to filter a series in pandas 
Python :: if string in list py 
Python :: terminal output redirect to a file 
Python :: run multiple test cases pytest 
Python :: iterating index array python 
Python :: python txt to parquet 
Python :: how to set numerecal index in pandas 
Python :: python check for alphanumeric characters 
Python :: convex hull python 
Python :: absolute url 
Python :: how to define functions in python 
Python :: reverse array python 
Python :: how to strip white space of text in python? 
Python :: django trim string whitespace 
Python :: tensorflow metrics accuracy 
Python :: python matrix 
Python :: create virtual env pyhton3 
Python :: subset in python 
Python :: django sign up 
Python :: remove from list if not maches in list 
Python :: python threading return value 
Python :: python add 1 to 100 
Python :: strip whitespace python 
Python :: big comments python 
Python :: python read input 
Python :: scipy check normal distribution 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =