libearth.compat — Compatibility layer¶
This module provides several subtle things to support multiple Python versions (2.6, 2.7, 3.2, 3.3) and VM implementations (CPython, PyPy).
-
libearth.compat.UNICODE_BY_DEFAULT= False¶ (
bool) Whether the Python VM uses Unicode strings by default. It must beTrueifPY3or IronPython.
-
libearth.compat.binary(string, var=None)¶ Makes
stringtostrin Python 2. Makesstringtobytesin Python 3 or IronPython.Parameters: - string (
bytes,str,unicode) – a string to cast it tobinary_type - var (
str) – an optional variable name to be used for error message
- string (
-
libearth.compat.binary_type¶ (
type) Type for representing binary data.strin Python 2 andbytesin Python 3.alias of
str
-
libearth.compat.encode_filename(filename)¶ If
filenameis atext_type, encode it tobinary_typeaccording to filesystem’s default encoding.
-
libearth.compat.file_types= (<class 'io.RawIOBase'>, <type 'file'>)¶
-
libearth.compat.string_type¶ (
type) Type for text data.basestringin Python 2 andstrin Python 3.alias of
basestring
-
libearth.compat.text(string)¶ Makes
stringtostrin Python 3 or IronPython. Does nothing in Python 2.Parameters: string ( bytes,str,unicode) – a string to cast it totext_type