title: Specifying type hint using the return type of a function
body: <p>I want to hint the type of a variable as the return type of a specific function, (without having to manually specify what the return type of the function is).</p>
  
  <p>I am unable to extract the return value type from the function in a way that it can be used as a hint for another variable.</p>
  
  <pre class="lang-py prettyprint-override"><code>def dostuff() -&gt; T:
      StuffContainer = namedtuple("StuffContainer", ["x", "y"])
      return StuffContainer(1, 2)
  
  def getX(a : T):
      return a.x
  </code></pre>
  
  <p>The C++ equivalent of what I want done:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>auto dostuff() {
      struct data {
          int x;
          int y;
      };
      return data {1, 2};
  }
  
  int getX(decltype(dostuff()) a) {
      return a.x;
  }
  </code></pre>