This module provides a thin compatibility layer between Python 2.7 and 3.x. Various objects are aliased as follows:

Exported object Points to in 2.x Points to 3.x
safe_bytes bytes() lambda x: bytes(x,"utf-8")
safe_str str() lambda x: x.decode("utf-8")
cStringIO cStringIO io
StringIO StringIO io
xrange xrange() range()
quote urllib.quote() urllib.parse.quote()
unquote urllib.quote() urllib.parse.unquote()
quote_plus urllib.quote_plus() urllib.parse.quote_plus()
unquote_plus urllib.unquote_plus() urllib.parse.unquote_plus()
ifilter itertools.ifilter() filter()

Also, one function is defined:

Function Action
get_func_code() Retrieves function.func_code in 2.x, function.__code__ in 3.x[source]

Return function code attribute for function func

Version Function attribute
2.x func_code
3.x _code
func : function

Query function


Function code