strings in Python (newbie)
Tim Hoffman
timh at zute.net
Wed Mar 12 09:16:01 EST 2003
Hi
Those aren't strings. They are fixed length char arrays.
Strings are null terminated.
How you do it all depends on what you are going to be doing with them
In python you could use a list on ints (array) or you could
Sconnection = chr(0)*56
or
EstabSession = "\x08\x00\0x01 ...... etc
or look at the Py_Object stuff and work directly with
C data types.
Rgds
Tim
zif wrote:
> Hi All,
>
> What would be in Python an equivalent to the following C language
> strings:
>
> unsigned char Sconnection[56] = {
> 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0 };
>
> unsigned char EstabSession[56] = {
> 8, 0, 1, 0, 0, 0, 0, 0,
> 0, 1, 0, 0, 0, 0, 0, 0,
> 0, 1, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 1, 0xc0,
> 0, 0, 0, 0, 0x10, 0x0e, 0, 0,
> 1, 1, 0x4f, 1, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0 };
>
> Thanks,
> zif
More information about the Python-list
mailing list