In general, you can pack any of the most common XDR data types by
calling the appropriate pack_type() method. Each method
takes a single argument, the value to pack. The following simple data
type packing methods are supported: pack_uint(),
pack_int(), pack_enum(), pack_bool(),
pack_uhyper(), and pack_hyper().
Packs a list of homogeneous items. This method is useful for
lists with an indeterminate size; i.e. the size is not available until
the entire list has been walked. For each item in the list, an
unsigned integer 1 is packed first, followed by the data value
from the list. pack_item is the function that is called to pack
the individual item. At the end of the list, an unsigned integer
0 is packed.
For example, to pack a list of integers, the code might appear like
p = xdrlib.Packer()
p.pack_list([1, 2, 3], p.pack_int)
Packs a fixed length list (array) of homogeneous items. n
is the length of the list; it is not packed into the buffer,
but a ValueError exception is raised if
len(array) is not equal to n. As above,
pack_item is the function used to pack each element.