[Numpy-discussion] why type(array(1).tolist()) is int?
dmitrey
dmitrey.kroshko at scipy.org
Wed Oct 1 09:57:26 EDT 2008
Alan G Isaac wrote:
> On 10/1/2008 9:04 AM dmitrey apparently wrote:
>
>> why array(1).tolist() returns 1? I expected to get [1] instead.
>>
>
> I guess I would expect it not to work at all.
> Given that it does work, this seems the best result.
> What list shape matches the shape of a 0-d array?
>
> What is the use case that makes this seem wrong?
>
Because I just expect something.tolist() return *Type* list, not *Type*
integer. tolist documentation says "Return the array as a list or
nested lists" and nothing about possibility to return anything else.
As for my situation I store the list in my data field and then call
for item from prob.my_list: do_something()
D.
> Alan Isaac
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
>
More information about the NumPy-Discussion
mailing list