Reputation: 2202
I tried printing a variable in a python code that I have and I got this:
[array([ 1., 0.]), array([ 0., 1.]), array([ 0., 1.]), array([ 1., 0.])]
What does this code snippet mean?
Upvotes: 1
Views: 816
Reputation: 4770
If this is the same array as the one in the built in array module, then the constructor requires a typecode in order to properly initialize the object , in your case like so : array('d', [1. ,0.])
. Are you sure the code you have here works ? Assuming it could infer the typecode from the values passed into the initializer list, you would have a list of arrays
Upvotes: 0
Reputation: 42748
You should best know, what it means. It is a list with four array-objects.
Upvotes: 0
Reputation: 26572
This seems to be a list containing Numpy arrays
, although without more information I can't assure that.
>>> from numpy import array
>>> my_var = [array([ 1., 0.]), array([ 0., 1.]), array([ 0., 1.]), array([ 1., 0.])]
>>> print(my_var)
[array([ 1., 0.]), array([ 0., 1.]), array([ 0., 1.]), array([ 1., 0.])]
>>> print(type(my_var))
<type 'list'>
>>> print(type(my_var[0]))
<type 'numpy.ndarray'>
Upvotes: 3