'int' object has no attribute '__getitem__' on a non-integer object
<p>In looking at other answers to this issue I found that the object was usually an integer so i constructed a simple example showing it is not and integer (or so I think), <strong>this code:</strong></p>

<pre><code>import numpy as np
a=np.arange(2,10)
print '1: ', a
print '2: ', a.size
print '3: ', a[3:] #this shows this is not an integer
print '3a: ', len(a[3:]) #len works
print '4: ', a.size[3:] #but yet size does not work
</code></pre>

<p><strong>yields:</strong> ============</p>

<pre><code>1:  [2 3 4 5 6 7 8 9]

2:  8

3:  [5 6 7 8 9]

4: 
------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-12-5c4b06ceceba&gt; in &lt;module&gt;()

  4 print '2: ', a.size

  5 print '3: ', a[3:] *#this shows this is not an integer*

----&gt; 6 print '4: ', a.size[3:] *#but yet size does not work*

TypeError: 'int' object has no attribute '__getitem__'
</code></pre>

<p>======================</p>

<p>As you can see a[3:] is not an integer  - what am I doing wrong?</p>

<p>If you want the size of <code>a[3:]</code> then try:</p>

<pre><code>&gt;&gt;&gt; a[3:].size
5
</code></pre>

<p>By writing <code>a.size[3:]</code> what you are trying to do is <code>index</code> over an <code>integer</code> as <code>a.size</code> is an <code>integer</code>.</p>

python