Robert Kern wrote:
>>> from numpy import *
>>> y = [116, 114, 121, 32, 116, 104, 105, 115]
>>> a = array(y, dtype=uint8)
>>> z = a.tostring()
>>> z
'try this'
Very nice! Thanks also to Paul and Travis!
Alan Isaac
--
http://mail.python.org/mailman/listinfo/python-list
David Isaac wrote:
y
> [116, 114, 121, 32, 116, 104, 105, 115]
z=''.join(chr(yi) for yi in y)
z
> 'try this'
>
> What is an efficient way to do this if y is much longer?
> (A numpy solution is fine.)
Here's another numpy solution just for fun:
import numpy
z = numpy.array(y,dtype=
"David Isaac" <[EMAIL PROTECTED]> writes:
> >>> y
> [116, 114, 121, 32, 116, 104, 105, 115]
> >>> z=''.join(chr(yi) for yi in y)
> >>> z
> 'try this'
>
> What is an efficient way to do this if y is much longer?
import array
z = array.array('B',y).tostring()
--
http://mail.python.org/mailman/list
David Isaac wrote:
y
> [116, 114, 121, 32, 116, 104, 105, 115]
z=''.join(chr(yi) for yi in y)
z
> 'try this'
>
> What is an efficient way to do this if y is much longer?
> (A numpy solution is fine.)
With numpy, something like the following:
>>> from numpy import *
>>> y = [116,
>>> y
[116, 114, 121, 32, 116, 104, 105, 115]
>>> z=''.join(chr(yi) for yi in y)
>>> z
'try this'
What is an efficient way to do this if y is much longer?
(A numpy solution is fine.)
Thanks,
Alan Isaac
--
http://mail.python.org/mailman/listinfo/python-list