From 2ec5cd5956f00b31faa2a0d6ab7186abfe8ad78a Mon Sep 17 00:00:00 2001 From: Prodesire Date: Mon, 8 Jan 2018 21:16:07 +0800 Subject: [PATCH] add doc for string.boolean --- docs/string.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/string.rst b/docs/string.rst index fb7827b..ee544c6 100644 --- a/docs/string.rst +++ b/docs/string.rst @@ -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