title: How to get a tuple out of a generator? Best Practice
body: <p>I'm a neophyte programmer and I wanted to create a generator that would return me two values that I would use in another function as a tuple.</p>
  
  <p>I don't understand why <code>tuple(function_1(a,b))</code> returns <code>((1, 2),)</code> while <code>tuple(function_2(a,b))</code> will return a correct tuple.</p>
  
  <p>I wonder what is going on here and what is the best syntax and eventually know if it is possible to retrieve a tuple from <code>function_1</code>.</p>
  
  <p>Thanks in advance for any explanations!</p>
  
  <pre><code>&gt;&gt;&gt; def function_1(a,b):
  ...     yield a,b
  ...
  &gt;&gt;&gt; def function_2(a,b):
  ...     yield a
  ...     yield b
  ...
  &gt;&gt;&gt; a = 1
  &gt;&gt;&gt; b = 2
  &gt;&gt;&gt;
  &gt;&gt;&gt; function_1(a,b)
  &lt;generator object function_1 at 0x1007931b0&gt;
  &gt;&gt;&gt; function_2(a,b)
  &lt;generator object function_2 at 0x1007931f8&gt;
  &gt;&gt;&gt; tuple(function_1(a,b))
  ((1, 2),)
  &gt;&gt;&gt; tuple(function_2(a,b))
  (1, 2)
  &gt;&gt;&gt; for item in function_1(a,b):
  ...    print(item)
  ...
  (1, 2)
  &gt;&gt;&gt; for item in function_2(a,b):
  ...    print(item)
  ...
  1
  2
  </code></pre>