Skip to content
A extremely light Python library (written in mainly C) in order to parse arguments, designed for chatbot libraries.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
parsethoseargs
.gitignore
.travis.yml
LICENSE
README.md
setup.py
test.py

README.md

Build Status

ParseThoseArgs

A extremely light Python library (written in mainly C) in order to parse arguments, designed for chatbot libraries.

Usage

The argument parser can be initialised with the following:

from parsethoseargs import ArgParser
parser = ArgParser(<text>, [ignore_quotes (defaults to False)])

In order to get the next argument from it, simply call next with the parser as a argument. The parser will raise StopIteration when all arguments have been parsed:

arg_count = 1
while True:
    try:
        print("Argument {}: {}".format(arg_count, next(parser)))
    except StopIteration:
        break
    arg_count += 1

If you want to get the remaining bit of the string being parsed, you can use the property parser.remaining.

The parser will split arguments at spaces unless there are quotes. If there are quotes, it will include everything (including spaces) inside of them. If there is one quote, everything after it will be a argument.

You can’t perform that action at this time.