[Python-ideas] Allow function to return multiple values

Mark E. Haase mehaase at gmail.com
Fri Jun 9 08:46:49 EDT 2017


On Thu, Jun 8, 2017 at 4:27 PM, Abe Dillon <abedillon at gmail.com> wrote:

> >>> a, *b = 1, 2, 3, 4, 5   # NOTE: Most itterables unpack starred
> variables as a list
> >>> type(b)
> <class 'list'>
>
> >>> a, *b = "except strings"
> >>> type(b)
> <class 'str'>
>

I was just playing around with this, and on Python 3.5.3, I see strings
unpacked as lists:

>>> first, *rest = 'spam'
>>> type(rest)
<class 'list'>

Am I doing something different, or is this something that changed in the
language?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170609/f2de3215/attachment-0001.html>


More information about the Python-ideas mailing list