How does Python return multiple values from a function?
<p>I have written the following code:</p>

<pre><code>class FigureOut:
   first_name = None
   last_name = None
   def setName(self, name):
      fullname = name.split()
      self.first_name = fullname[0]
      self.last_name = fullname[1]

   def getName(self):
      return self.first_name, self.last_name

f = FigureOut()
f.setName("Allen Solly")
name = f.getName()
print (name)
</code></pre>

<p>I get the following <strong>Output:</strong></p>

<pre><code>('Allen', 'Solly')
</code></pre>

<p>Whenever multiple values are returned from a function in python, does it always convert the multiple values to a <strong>list of multiple values</strong> and then returns it from the function?</p>

<p><em>Is the whole process same as converting the multiple values to a <code>list</code> explicitly and then returning the list, for example in JAVA, as one can return only one object from a function in JAVA?</em></p>

<p>Python functions always return a unique value. The comma operator is the constructor of tuples so <code>self.first_name, self.last_name</code> evaluates to a tuple and that tuple is the actual value the function is returning.</p>

python function python-3.x return