howto make Python list from numpy.array?

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sun May 6 19:17:43 EDT 2007


On Sun, 06 May 2007 13:06:56 -0700, dmitrey wrote:

> Thanks all.
> I tried all the approaches but they don't work in my situation
> I have a variable x that can be
> x = 1
> x = [1, 2, 3]
> x = numpy.array([1,2,3])
> so all troubles are with 1st case

And yet your question was about the third case:

"howto make Python list from numpy.array?"


You should have asked:

How do I make a Python list from an int?

And the answer would be:

x = 1
lst = [x]

Another answer would be:

x = 1
lst = ["existing", "list"]
lst.append(x)



-- 
Steven.




More information about the Python-list mailing list