title: Raise error in ternary statement in python, without using classic if/else syntax
body: <p>Is it possible in python to <strong>directly</strong> raise an error in a ternary statement?</p>
  
  <p>As in:</p>
  
  <pre><code>import numpy as np
  y = np.random.rand(200, 5, 5)
  
  y = (y[:, None] if y.ndim == 1 
      else y if y.ndim == 2 
      else raise ValueError('`y` must be given as a 1D or 2D array.'))
  </code></pre>
  
  <p>Of course it is possible to do this with a simple if/elif/else statement. Thus I'm asking specifically for a solution using a "one-line" ternary statement.</p>
  
  <p>Just for clarification:<br>
  I know that ternary statements are not intended to raise errors and that it is not <em>good style</em> according to PEP8 etc.. I am just asking <strong>if it is possible at all</strong>.</p>