PyCon UK 2012の動画を見てたら面白いもの見つけたのでメモ。 docoptというもので、コマンドラインツールを作るときに、docstringを解析して引数をパースしてくれる優れもの。 http://docopt.org/ docstringのUsageセクションに用例を書いておくとそれを解析してくれる。例えば、 #!/usr/bin/env python # -*- coding: utf-8 -*- """Test Usage: test ship new <name> test ship <name> move <x> <y> [--speed=<kn>] test ship <name> (<from> <to>)... test ship shoot <x> <y> test mine (set|remove) <x> <y> [--moored|--drifting]