Python language/syntax usage
<p>New to python but ran into something I don't understand.  The following line of code:</p>

<pre><code>diff = features[0:] - test[0]    # &lt;- this is what I don't get
</code></pre>

<p>is used thusly:</p>

<pre><code>x = diff[i] 
</code></pre>

<p>to return the element-wise difference between <code>features[i]</code> and <code>test[0]</code>.  Can anyone point to a language reference for this or explain it?  I understand how the result can be developed using "def" or "lambda" but I don't understand the construction.</p>

<p>thanks!</p>

<p><code>feature</code> appears to be a <a href="http://www.numpy.org/" rel="nofollow">Numpy</a> array. Numpy arrays 'broadcast' scalar operations to the whole array.</p>

<pre><code>import numpy as np
asd = np.full([10,10], 10, np.int64)
asd /= 5
print asd # prints a 10x10 array of 2s
</code></pre>

python