how do i pack and unpack messages in python?

Shaun shogan at iel.ie
Thu Apr 20 15:20:56 CEST 2000


im still new to python and i have this problem to solve and i have not a
clue where to start can anyone please put me on the right track...

say i have a form, with the values:

Name: Shaun Hogan
Address: Anytown, Anywhere
Credit Card Number: 1234567890

so i have 3 values that i want to pack into a message so as the info can be
sent (but dont worry about th3 sending bit for the mo)

i have a message that looks like this when broken down:
(makes more sense if you read from the bottom up!)

{
Message:
    (type)int(value)id            // the message has its id
    (type)int(value)subid       //and subid
     NVsequence                 //and list of NV pairs
NVsequence:
     NV pair []                   //NVsequence consists of an array/list of
NV
                                         // pairs
NV pair:
     int name                       //we assign id names to the values
     value v                          //eg. [14:"shaun"], [20:"Any..."],
[34:1234...]
                                         //creating [name:value] pairs
Value:
     char type                    //here we determine and state the type of
the
     void *pVal                 //values, "shaun"=string,
"Anyt...,Anyw.."=list,
                                       //1234567890=int, and we establish a
*pointer
                                       //to the values.

Value List:                       //here we have a list of values
     Value[]
                //"shaun","Anytown,Anywhere",1234567890]       }

so i now have a message that looks like:

id                       : 10
subid                  :13
NV sequence :   {14, "shaun"-string
                         {20, ["Anytown, Anywhere"]-list
                         {34, 1234567890-int


i want to pack the message to look like this:

10 fs 13 fs 14 fs s shaun fs 20 fs l s anytown fs s anywhere fs i 1234567890
gs gs

(NV=Name Value Pair, fs=field seperator, s=string, i=int, l=list, group
seperator)

can anyone please tell me how id go about manipulating the strings so as i
can join them using field seperators, any ideas anyone, or even tell me
where i might find out how to do this problem.

Thanks a Million
Shaun

=====================
Shaun Hogan
Interactive Enterprise Ltd.
alt. E-mail : shaun_hogan at yahoo.com
+353 86 8342529






More information about the Python-list mailing list