title: Why is starred iterable unpacking in a return statement invalid syntax without parentheses before Python 3.8?
body: <p>The Python language (especially 3.x) allows very general <em>unpacking</em> of iterables, a simple example of which is</p>
  
  <pre><code>a, *rest = 1, 2, 3
  </code></pre>
  
  <p>Over the years, this unpacking has been gradually generalized (see e.g. <a href="https://www.python.org/dev/peps/pep-3132/" rel="noreferrer">PEP 3132</a> and <a href="https://www.python.org/dev/peps/pep-0448/" rel="noreferrer">PEP 448</a>), allowing it to be used in more and more circumstances. As so, I was surprised to discover that the following is invalid syntax in Python 3.6 (and remains so in Python 3.7):</p>
  
  <pre><code>def f():
      rest = [2, 3]
      return 1, *rest  # Invalid
  </code></pre>
  
  <p>I can make it work by encapsulating the returned tuple in parentheses like so:</p>
  
  <pre><code>def f():
      rest = [2, 3]
      return (1, *rest)  # Valid
  </code></pre>
  
  <p>The fact that I use this in a <code>return</code> statement seems to be important, as</p>
  
  <pre><code>t = 1, *rest
  </code></pre>
  
  <p>is indeed legal and results in the same with and without parentheses.</p>
  
  <p>Have this case simply been forgotten by the Python developers, or are there any reason why this case is invalid syntax?</p>
  
  <h3>Why I care</h3>
  
  <p>This breaks an important contract I thought I had with the Python language. Consider the following (also valid) solution:</p>
  
  <pre><code>def f():
      rest = [2, 3]
      t = 1, *rest
      return t
  </code></pre>
  
  <p>Normally when I have code like this, I consider <code>t</code> to be a temporary name, which I ought to be able to get rid of simply be replacing <code>t</code> in the bottom line with its definition. In this case though, this leads to the invalid code</p>
  
  <pre><code>def f():
      rest = [2, 3]
      return 1, *rest
  </code></pre>
  
  <p>It's of course no big deal to have to place parentheses around the return value, but usually additional parentheses are only needed to distinguish between several possible outcomes (grouping). Here this is not the case, as leaving out the parentheses does not produce some other unwanted behavior, but rather no behavior at all.</p>
  
  <h3>Update</h3>
  
  <p>Since Python 3.8 (see item 7 on <a href="https://docs.python.org/3.8/whatsnew/3.8.html#other-language-changes" rel="noreferrer">this list</a>), the generalized syntax discussed above is now valid.</p>