[Python-ideas] Allow function to return multiple values

אלעזר elazarg at gmail.com
Thu Jun 1 10:27:13 EDT 2017


What is the difference between returning a tuple and returning two values?
I think at least theoretically it's different wording for precisely the
same thing.

Elazar

בתאריך יום ה׳, 1 ביונ' 2017, 17:21, מאת Markus Meskanen ‏<
markusmeskanen at gmail.com>:

> Why isn't a tuple enough? You can do automatic tuple unpack:
>
>     v1, v2 = return_multiplevalues(1, 2)
>
>
> On Jun 1, 2017 17:18, "joannah nanjekye" <nanjekyejoannah at gmail.com>
> wrote:
>
> Hello Team,
>
> I am Joannah. I am currently working on a book on python compatibility and
> publishing it with apress. I have worked with python for a while we are
> talking about four years.
>
> Today I was writing an example snippet for the book and needed to write a
> function that returns two values something like this:
>
> def return_multiplevalues(num1, num2):
>      return num1, num2
>
>  I noticed that this actually returns a tuple of the values which I did
> not want in the first place.I wanted python to return two values in their
> own types so I can work with them as they are but here I was stuck with
> working around a tuple.
>
> My proposal is we provide a way of functions returning multiple values.
> This has been implemented in languages like Go and I have found many cases
> where I needed and used such a functionality. I wish for this convenience
> in python so that I don't  have to suffer going around a tuple.
>
> I will appreciate discussing this. You may also bring to light any current
> way of returning multiple values from a function that I may not know of in
> python if there is.
>
> Kind regards,
> Joannah
>
> --
> Joannah Nanjekye
> +256776468213
> F : Nanjekye Captain Joannah
> S : joannah.nanjekye
> T : @Captain_Joannah
> SO : joannah
>
>
> *"You think you know when you learn, are more sure when you can write,
> even more when you can teach, but certain when you can program." Alan J.
> Perlis*
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170601/06217236/attachment.html>


More information about the Python-ideas mailing list