Mailing List Archive

Can't work this XDR out
Whilst trying to pack a list xdr packer asks for

(list, pack_item)

what is the pack_item can't work this out as there are no examples
Can't work this XDR out [ In reply to ]
Matthew Robert Gallagher writes:
> Whilst trying to pack a list xdr packer asks for
>
> (list, pack_item)
>
> what is the pack_item can't work this out as there are no examples

Matthew,
pack_item will typically be another method from the same packer
object. For example, to pack a list of ints, use this:

import xdrlib
p = xdrlib.Packer()
p.pack_list([1, 2, 3], p.pack_int)

I hope this helps. I'll add an example to the documentation.


-Fred

--
Fred L. Drake, Jr. <fdrake@acm.org>
Corporation for National Research Initiatives