Python get a value from numpy.ndarray by [index]
<pre><code>import numpy as np
ze=np.zeros(3)
print(ze[0]) # -&gt;  0
</code></pre>

<p>I am pretty new to Python (3.5.2)</p>

<p>I learned 'list' in python and to show the i th element in list1</p>

<pre><code>print (list1[i])
</code></pre>

<p>but, even 'np.zeros(3)' is ndarray,  a class in NumPy,
 it can be used as the 'list' like above.</p>

<p>What is happening on that?</p>

<p>I am pretty new but I have worked on Java..so I hope the issues can be understood...</p>

<p>I guess this question is too early for one who just learned range() and not known how to define functions(methods?)..</p>

<p>But please let me know how to achieve the access by operator [].</p>

<p>Maybe it will be usefull, when I really start to Python.</p>

<p>If you want to implement a class that can return a value using the [] operator. Then implement the <code>__getitem__(self, key)</code> function in the class, see <a href="https://docs.python.org/2/reference/datamodel.html#emulating-container-types" rel="nofollow">https://docs.python.org/2/reference/datamodel.html#emulating-container-types</a>.</p>

python numpy