def boolean(text):
    """
    An alternative to the "bool" argument type which interprets string
    values.
    """

    tmp = text.lower()
    if tmp.isdigit():
        return bool(int(tmp))
    elif tmp in ('t', 'true', 'on', 'yes'):
        return True
    elif tmp in ('f', 'false', 'off', 'no'):
        return False

    raise ValueError("invalid Boolean value %r" % text)
An alternative to the "bool" argument type which interprets string
    values.