import argparse
import os
PATH_HOME = os.path.dirname(os.path.realpath(__file__))
parser = argparse.ArgumentParser(description="Purpose: my program")
parser.add_argument('--foo','-f',
type = str, # The type of argument input
nargs = '?', # Accepts 0 or 1 arguments
dest = 'file_name', # Parse_args property NAME
action = 'store', # Mode for default action
const = 'default2.txt', # Default value for the flag
required = False, # Whether are argument must be provided
default = 'default1.txt', # Default argument if no flags are present
help = 'path to file', # Help on this flag parameter
metavar = 'Path to this thing' # Used when -h is invoked
)
print(PATH_HOME)
print(parser.parse_args())
print(parser.parse_args().file_name)
print(parser.parse_args().file_name.split())
if _name_ == "__main__":
pass
DONATE:
---------------
PAT: / rezatahirkheli
PP: https://www.paypal.com/paypalme/rezat...
BTC: 3EUQBWZKX9Vcwdffd3cUGATQopxrAQQxJ9
LTC: MBXE6hJgxxFYSD8SjmR7sHCHGTqFXmNGoU
Watch video Using Python's Argparse Flags: Automation Application online without registration, duration hours minute second in high quality. This video was added by user ZeroLife 18 August 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 239 once and liked it 1 people.