Why does Python array moduel handle strings and lists differently?

Posted by Casey on Stack Overflow See other posts from Stack Overflow or by Casey
Published on 2010-05-02T08:56:14Z Indexed on 2010/05/02 8:57 UTC
Read the original article Hit count: 219

I'm having trouble understanding the result of the following statements:

>>> from array import array
>>> array('L',[0xff,0xff,0xff,0xff])
array('L', [255L, 255L, 255L, 255L])


>>> from array import array
>>> array('L','\xff\xff\xff\xff')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: string length not a multiple of item size

© Stack Overflow or respective owner

Related posts about python

Related posts about array