pyneric.future¶
pyneric.future module
This is equivalent to future.builtins with additions and customizations.
-
pyneric.future.
python_2_unicode_compatible
(cls)[source]¶ DEPRECATED: Use this method from its source (
future.utils
). Withfrom pyneric.future import *
, it can be referenced withfuture.python_2_unicode_compatible
.
-
pyneric.future.
ensure_text
(value, encoding='utf-8', errors='strict', coerce=False)[source]¶ Return the text representation of the given string.
Parameters: - bytes/str/unicode (value) – string value
- str (errors) – name of encoding used if
value
is not text - str – decode option used if
value
is not text - coerce (bool) – whether to attempt to coerce
value
to text
Returns: text representation of
value
Return type: unicode
if Python 2; otherwise,str
Raises: - TypeError – if
value
is not a str, unicode, nor bytes - UnicodeDecodeError – if
value
cannot be decoded
The primary use case for this function is as a shortcut for a library providing support for Python 2 and 3 to ensure that a provided string value can be interpreted as text.