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
dataisNone, thenNonewill be returned.If you’d rather convert
Noneinto a blank string, useif_node="", like so:>>> repr(stringify(None)) 'None' >>> stringify(None, if_none="") ''