[a,b,c,d] = 1,2,3,4

Jussi Piitulainen harvested.address at is.invalid
Tue Aug 25 18:19:44 CEST 2015


Ian Kelly writes:
> On Tue, Aug 25, 2015 at 9:32 AM, Skip Montanaro wrote:
>> On Tue, Aug 25, 2015 at 10:24 AM, Jussi Piitulainen wrote:
>>>
>>> When I try it today, round brackets also work, both in 2.6.6 and
>>> 3.4.0 - no idea what version it was where they failed or if I'm
>>> imagining the whole thing.
>>
>> You are imagining the whole thing. Either that, or you had some other
>> problem with your tuple unpacking which kept it from working. That
>> has been a part of the language as far back as I can remember. I
>> started using Python around the 1.0 timeframe.
>
> My guess is that Jussi was trying to unpack a sequence of a single
> element like this:
>
>     (a) = some_sequence
[snip]

It wasn't that. It was a known number of tab-separated fields that I
wanted to name individually, like this:

        ID, FORM, LEMMA, POS, MOR, FEATS, \
            HEAD, REL, DEPS, MISC \
            = line.split('\t')

That's from actual code but not necessarily from the place where I first
tried and failed to use parentheses. It didn't occur to me to try square
brackets, so I got in the habit of using backslashes as above. (That
script is dated in January 2015. The something that happened happened
some months before that. But it may have been a hallucination.)


More information about the Python-list mailing list