compat - Python compatibility helpers

The compat module is for internal purposes of your package or application and should not be used outside of it.

compat.ISPYTHON2

True, if executed in a Python 2.x compatible interpreter, False otherwise.

compat.ISPYTHON3

True, if executed in a Python 3.x compatible interpreter, False otherwise.

compat.long([x[, base]])

Note

Only defined for Python 3.x, for which it is the same as int().

compat.unichr(i)

Note

Only defined for Python 3.x, for which it is the same as chr().

compat.unicode(string[, encoding[, errors]])

Note

Only defined for Python 3.x, for which it is the same as str().

compat.callable(x) → bool

Note

Only defined for Python 3.x, for which it is the same as isinstance(x, collections.Callable)

compat.byteify(x : string, enc : string) → bytes

Converts a string to a bytes() object.

compat.stringify(x : bytes, enc : string) → string

Converts a bytes() to a string object.

compat.isiterable(x) → bool

Shortcut for isinstance(x, collections.Iterable).

compat.platform_is_64bit() → bool

Checks, if the interpreter is 64-bit capable.

@compat.deprecated

A simple decorator to mark functions and methods as deprecated. This will print a deprecation message each time the function or method is invoked.

compat.deprecation(message : string) → None

Prints a deprecation message using the warnings.warn() method.

exception compat.UnsupportedError(obj : object[, msg=None])

Indicates that a certain class, function or behaviour is not supported in the specific execution environment.

@compat.experimental

A simple decorator to mark functions and methods as experimental. This will print a warning each time the function or method is invoked.

exception compat.ExperimentalWarning(obj : object[, msg=None])

Indicates that a certain class, function or behaviour is in an experimental state.