add doc for string.boolean

This commit is contained in:
Prodesire 2018-01-08 21:16:07 +08:00
parent 0ada2fa96c
commit 2ec5cd5956
1 changed files with 19 additions and 0 deletions

View File

@ -83,3 +83,22 @@ String
>>> from pydu.string import sort
>>> sort('dabc')
'abcd'
.. py:function:: pydu.string.boolean(obj)
Convert obj to a boolean value.
If obj is string, obj will converted by case-insensitive way:
* convert `yes`, `y`, `on`, `true`, `t`, `1` to True
* convert `no`, `n`, `off`, `false`, `f`, `0` to False
* raising TypeError if other values passed
If obj is non-string, obj will converted by ``bool(obj)``.
>>> from pydu.string import boolean
>>> boolean('yes')
True
>>> boolean('no')
False