StringBool

Converts a string to a boolean.

Values like 'true' and 'false' are considered True and False, respectively; anything in true_values is true, anything in false_values is false, case-insensitive). The first item of those lists is considered the preferred form.

>>> s = StringBoolean()
>>> s.to_python('yes'), s.to_python('no')
(True, False)
>>> s.to_python(1), s.to_python('N')
(True, False)
>>> s.to_python('ye')
Traceback (most recent call last):
    ...
Invalid: Value should be 'true' or 'false'

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
string:
Value should be %(true)r or %(false)r

Attributes

a false_values

['false', 'f', 'no', 'n', 'off', '0']

a gettextargs

{}

a strip

False

a true_values

['true', 't', 'yes', 'y', 'on', '1']

a accept_python

True

a __singletonmethods__

('to_python', 'from_python', 'message', 'all_messages', 'subvalidators')

a declarative_count

41

a use_builtins_gettext

True

a __unpackargs__

()

a compound

False

a not_empty

False

a __mutableattributes__

()

a repeating

False

Methods

f __initargs__(self, new_attrs) ...

f __call__(self, *args, **kw) ...

f __classinit__(cls, new_attrs) ...

f __init__(self, *args, **kw) ...

f __sourcerepr__(self, source, binding=None) ...

f __classsourcerepr__(cls, source, binding=None) ...

See the source for more information.