Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A command-line / stdin argument handler that serves as a simple replacement for python's argparse module
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


A command-line argument handler that serves as a simple replacement for python's argparse module


Should work on any Linux platform with python 2.7*


To begin parsing command line arguments, call parse_args and pass in the name of your script as you wish it to be displayed, along with a list of your argument tuples

args = parse_args("my-program", [(arg1..),(arg2...)...])

There are two types of command line arguments you can add to your program. Optional arguments, which are passed as a 4 tuple, or Positional arguments which, when specified, are required by your program and are passed as a 2-Tuple, like so:

Argument type examples

Flagged / Optional argument

(short-flag, long-flag, description, argument-required)


  • short-flag: The single letter flag for this argument passed with a '-' prepended via the command line.
  • long-flag: The full name for the flag argument, passed with '--' prepended via the command line.
  • description: the text description of the argument
  • argument-required: set to "True" if the flag accepts an argument or "False" if the flag is simply an on/off value

Requred / Positional argument

(variable-name, description)


  • variable-name: the full name of the variable (spaces and dashes get converted to underscores)
  • description: text description of the variable

Here's a short example of how easy it is to use this function

from args import parse_args

args = parse_args("test", 
        [('f', 'flag argument', 'This is a flag argument', False),
        ('a', 'accepts-param', 'This flag takes a parameter', True),
        ('positional', 'This is a positional argument and is required by this program')])

# Evaluate your arguments
if args.flag_argument:
    print args.flag_argument

if args.accepts_param:
    print args.accepts_param

print args.positional

Stdin vs Shell

Args will attempt to read all arguments from the shell initially. If no argument is specified it will fall back to reading from stdin.


  • The -h, or --help flag is created for you by default and help is only displayed when either -h or --help is passed
Something went wrong with that request. Please try again.