Python xdrlib Module
Example
Pack data into XDR format:
import xdrlib
packer = xdrlib.Packer()
packer.pack_int(42)
packer.pack_string(b'Hello')
data = packer.get_buffer()
print(f'Packed data: {data}')
Try it Yourself »
Definition and Usage
The xdrlib module converts between Python data types and XDR (External Data Representation) format.
Use it when you need to exchange binary data between different computer systems in a platform-independent way.
Note: This module is deprecated since Python 3.11 and will be removed in Python 3.13. XDR is rarely used in modern applications.
Members
Member | Description |
---|---|
Error | Exception raised when XDR packing or unpacking fails. |
Packer | Object for packing Python data into XDR format. |
Packer.get_buffer() | Get the packed data as bytes. |
Packer.pack_array() | Pack a list of items using a packing function. |
Packer.pack_bool() | Pack a boolean value. |
Packer.pack_bytes() | Pack a fixed-length byte string. |
Packer.pack_double() | Pack a double-precision float. |
Packer.pack_enum() | Pack an enumeration value (same as pack_int). |
Packer.pack_farray() | Pack a fixed-length array. |
Packer.pack_float() | Pack a single-precision float. |
Packer.pack_fopaque() | Pack fixed-length opaque data. |
Packer.pack_fstring() | Pack a fixed-length string. |
Packer.pack_hyper() | Pack a 64-bit integer. |
Packer.pack_int() | Pack a 32-bit signed integer. |
Packer.pack_list() | Pack a variable-length list. |
Packer.pack_opaque() | Pack variable-length opaque data. |
Packer.pack_string() | Pack a variable-length string. |
Packer.pack_uhyper() | Pack a 64-bit unsigned integer. |
Packer.pack_uint() | Pack a 32-bit unsigned integer. |
Packer.reset() | Clear the buffer to start fresh. |
Unpacker | Object for unpacking XDR data into Python types. |
Unpacker.done() | Check if all data has been unpacked. |
Unpacker.get_position() | Get the current unpacking position. |
Unpacker.reset() | Reset unpacking position to the start. |
Unpacker.set_position() | Jump to a specific position in the buffer. |
Unpacker.unpack_array() | Unpack an array using an unpacking function. |
Unpacker.unpack_bool() | Unpack a boolean value. |
Unpacker.unpack_bytes() | Unpack a fixed-length byte string. |
Unpacker.unpack_double() | Unpack a double-precision float. |
Unpacker.unpack_enum() | Unpack an enumeration value. |
Unpacker.unpack_farray() | Unpack a fixed-length array. |
Unpacker.unpack_float() | Unpack a single-precision float. |
Unpacker.unpack_fopaque() | Unpack fixed-length opaque data. |
Unpacker.unpack_fstring() | Unpack a fixed-length string. |
Unpacker.unpack_hyper() | Unpack a 64-bit integer. |
Unpacker.unpack_int() | Unpack a 32-bit signed integer. |
Unpacker.unpack_list() | Unpack a variable-length list. |
Unpacker.unpack_opaque() | Unpack variable-length opaque data. |
Unpacker.unpack_string() | Unpack a variable-length string. |
Unpacker.unpack_uhyper() | Unpack a 64-bit unsigned integer. |
Unpacker.unpack_uint() | Unpack a 32-bit unsigned integer. |