Assigning generator expressions to ctype arrays

Patrick Maupin pmaupin at gmail.com
Thu Oct 27 16:34:28 EDT 2011


Bug or misunderstanding?

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 32 * [0]
>>> x[:] = (x for x in xrange(32))
>>> from ctypes import c_uint
>>> x = (32 * c_uint)()
>>> x[:] = xrange(32)
>>> x[:] = (x for x in xrange(32))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Can only assign sequence of same size
>>>

Thanks,
Pat



More information about the Python-list mailing list