title: What is the most pythonic way to use len on a scalar?
body: <p>I read this question</p>
  
  <p><a href="https://stackoverflow.com/questions/16807011/python-how-to-identify-if-a-variable-is-an-array-or-a-scalar">python: how to identify if a variable is an array or a scalar</a></p>
  
  <p>but when using the following code I get a false on an <code>np.array</code> as can be demonstrated below.</p>
  
  <pre><code>import collections
  
  isinstance(np.arange(10), collections.Sequence)
  # returns false
  </code></pre>
  
  <p>I find it a bit annoying that I can't do <code>len(1)</code> and simply get <code>1</code>. </p>
  
  <p>The only work around I can think of is a <code>try except</code> statement such as the following:</p>
  
  <pre><code>a = 1
  try:
      print len(a)
  except TypeError:
      print 1
  </code></pre>
  
  <p>Is there a more Pythonic way to do this?</p>