Parse command-line arguments using introspective magic.

command-line, arguments, flags, argparse
pip install argent==0.01.1



Argent is a new argument parser for command-line programs in Python. It turns out Python already has objects that can take arbitrary arguments, supply defaults, and do things with them: they're called functions. For help messages, Argent uses some introspective magic on these functions and then analyzes your docstrings for more information. And you already detail your arguments meticulously in your docstrings, right?


  • Easy syntax; no cascades of text, as in argparse. Use the Python function syntax you already know and love, with decorators for specifying parsers and subparsers.
  • Cleverness founded in introspective magic; on the other hand, it's only a little more magic than docutils, for example. There's no black magic metaclass hacking here.
  • So long as you format your docstrings how Argent expects you too, you'll get beautiful detailed help messages.


This is about the simplest you can do:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from argent import Parser

def simplest():
    "Prints hello when you call it."
    print "hello!"


This program's help message (run python --help) is:

usage: [--h] 

Prints hello when you call it.

optional flags:
   --h, --help   Display this help message and exit.

Here's a more featureful example, and there are more over at this other page.


  • Flags that can take arguments -- like --flag argument.
  • Type checking; for now you have to assume everything will come in as strings.
  • Colorized help output?
  • Clean up the codebase, as always.
  • More documentation.