mirror of https://github.com/flaggo/pydu.git
add doc for string.boolean
This commit is contained in:
parent
0ada2fa96c
commit
2ec5cd5956
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue