stringify¶
-
privex.helpers.common.
stringify
(data: Optional[Union[str, bytes]], encoding='utf-8', if_none=None) → str[source]¶ Convert a piece of data into a string (from bytes) if it isn’t already:
>>> stringify(b"hello world") "hello world"
By default, if
data
isNone
, thenNone
will be returned.If you’d rather convert
None
into a blank string, useif_node=""
, like so:>>> repr(stringify(None)) 'None' >>> stringify(None, if_none="") ''