t.p.compat : module documentation

Part of twisted.python View Source

Compatibility module to provide backwards compatibility for useful Python features.

This is mainly for use of internal Twisted code. We encourage you to use the latest version of Python directly from your code, if possible.

Function inet_pton Undocumented
Function inet_ntop Undocumented
Function execfile Execute a Python script in the given namespaces.
Function cmp Compare two objects.
Function comparable Class decorator that ensures support for the special __cmp__ method.
Function nativeString Convert bytes or unicode to the native str type, using ASCII encoding if conversion is necessary.
Function reraise Undocumented
Function iterbytes 0 Undocumented
Function intToBytes 0 Undocumented
Function lazyByteSlice Return a copy of the given bytes-like object.
Function networkString 0 Undocumented
Function iterbytes Undocumented
Function intToBytes Undocumented
Function networkString Undocumented
def inet_pton(af, addr): (source)
Undocumented
def inet_ntop(af, addr): (source)
Undocumented
def execfile(filename, globals, locals=None): (source)
Execute a Python script in the given namespaces.

Similar to the execfile builtin, but a namespace is mandatory, partly because that's a sensible thing to require, and because otherwise we'd have to do some frame hacking.

This is a compatibility implementation for Python 3 porting, to avoid the use of the deprecated builtin execfile function.

def cmp(a, b): (source)
Compare two objects.

Returns a negative number if a < b, zero if they are equal, and a positive number if a > b.

def comparable(klass): (source)
Class decorator that ensures support for the special __cmp__ method.

On Python 2 this does nothing.

On Python 3, __eq__, __lt__, etc. methods are added to the class, relying on __cmp__ to implement their comparisons.

def nativeString(s): (source)
Convert bytes or unicode to the native str type, using ASCII encoding if conversion is necessary.
RaisesUnicodeErrorThe input string is not ASCII encodable/decodable.
TypeErrorThe input is neither bytes nor unicode.
def reraise(exception, traceback): (source)
Undocumented
def iterbytes 0(originalBytes): (source)
Undocumented
def intToBytes 0(i): (source)
Undocumented
def lazyByteSlice(object, offset=0, size=None): (source)
Return a copy of the given bytes-like object.

If an offset is given, the copy starts at that offset. If a size is given, the copy will only be of that length.

Parametersobjectbytes to be copied.
offsetint, starting index of copy.
sizeOptional, if an int is given limit the length of copy to this size.
def networkString 0(s): (source)
Undocumented
def iterbytes(originalBytes): (source)
Undocumented
def intToBytes(i): (source)
Undocumented
def networkString(s): (source)
Undocumented
API Documentation for Twisted, generated by pydoctor at 2013-11-08 22:07:30.