On Thu, 13 Mar 2008, Alexander Michael apparently wrote:
>  I wasn't sure if there was a magic numpy
> method to do the loop quickly (as the destination array is created 
> beforehand) without creating a temporary Python list, but I guess not. 
> The generator/list-comprehension is likely better than my prototype. 


Looks like I misunderstood your question:
you want an **array** of strings?
In principle you should be able to use ``fromiter``,
I believe, but it does not work.  BUG? (Crasher.)

Cheers,
Alan Isaac


>>> import numpy as N
>>> x = [1,2,3]
>>> fmt="%03d"
>>> N.array([fmt%xi for xi in x],dtype='S')
array(['001', '002', '003'],
      dtype='|S3')
>>> N.fromiter([xi for xi in x],dtype='float')
array([ 1.,  2.,  3.])
>>> N.fromiter([xi for xi in x],dtype='S')
Python crashes.


_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to