strings in Python (newbie)

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Wed Mar 12 09:30:16 EST 2003


zif wrote:
> 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,
[...]
> unsigned char EstabSession[56] = {
>     8, 0, 1, 0, 0, 0, 0, 0,
[...]

Technically, there is no Python equivalent because Python has no unsigned char 
datatype. However, you could perhaps use the Pythonic

Sconnection = [ 0 ] * 56
EstabSession = [ 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 ]

This might do for your purpose depending on the rest of the code.

Irmen





More information about the Python-list mailing list