[Python-ideas] Unpack of sequences

Ned Batchelder ned at nedbatchelder.com
Wed Aug 29 15:57:30 CEST 2012


On 8/29/2012 9:50 AM, Carlo Pires wrote:
> Hi,
>
> I was just wondering why unpack of sequences did not follow same 
> behavior of functions parameters. I mean:
>
> first, *rest = 'a b c'.split()
>
> should work in python, why doesn't it?
>

It does in Python 3:

Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> first, *rest = 'a b c'.split()
 >>> first
'a'
 >>> rest
['b', 'c']
 >>>


--Ned.



More information about the Python-ideas mailing list