Re: numbers to string

2006-10-25 Thread David Isaac
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

Re: numbers to string

2006-10-24 Thread Travis E. Oliphant
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=

Re: numbers to string

2006-10-24 Thread Paul Rubin
"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

Re: numbers to string

2006-10-24 Thread Robert Kern
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,

numbers to string

2006-10-24 Thread David Isaac
>>> 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