title: Is this the best way to add an extra dimension to a numpy array in one line of code?
body: <p>If k is an numpy array of an arbitrary shape, so <code>k.shape = (s1, s2, s3, ..., sn)</code>, and I want to reshape it so that <code>k.shape</code> becomes <code>(s1, s2, ..., sn, 1)</code>, is this the best way to do it in one line?</p>
  
  <pre><code>k.reshape(*(list(k.shape) + [1])
  </code></pre>