wand.compat — Compatibility layer
This module provides several subtle things to support multiple Python versions (2.6, 2.7, 3.2–3.5) and VM implementations (CPython, PyPy).
-
wand.compat.PY3= False (
bool) Whether it is Python 3.x or not.
-
wand.compat.binary(string, var=None) Makes
stringtostrin Python 2. Makesstringtobytesin Python 3.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 (
-
wand.compat.binary_type (
type) Type for representing binary data.strin Python 2 andbytesin Python 3.alias of
str
-
wand.compat.encode_filename(filename) If
filenameis atext_type, encode it tobinary_typeaccording to filesystem’s default encoding.
-
wand.compat.file_types= (<class 'io.RawIOBase'>, <type 'file'>) (
type,tuple) Types for file objects that havefileno().
-
wand.compat.nested(*args, **kwds) Combine multiple context managers into a single nested context manager.
This function has been deprecated in favour of the multiple manager form of the with statement.
The one advantage of this function over the multiple manager form of the with statement is that argument unpacking allows it to be used with a variable number of context managers as follows:
- with nested(*managers):
- do_something()
-
wand.compat.string_type (
type) Type for text data.basestringin Python 2 andstrin Python 3.alias of
basestring
-
wand.compat.text(string) Makes
stringtostrin Python 3. Does nothing in Python 2.Parameters: string ( bytes,str,unicode) – a string to cast it totext_type
-
wand.compat.text_type (
type) Type for representing Unicode textual data.unicodein Python 2 andstrin Python 3.alias of
unicode
-
class
wand.compat.xrange(stop) → xrange object The
xrange()function. Alias forrange()in Python 3.