Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95649

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

References <CAPM-O+y-FftPRv7_VqSG6JVp3ocr__yd=RuppLh5ZWcMg25v+g@mail.gmail.com> <935842626.955183.1440514765199.JavaMail.root@sequans.com>
Date 2015-08-26 23:04 +1000
Subject Re: [a,b,c,d] = 1,2,3,4
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.43.1440594254.11709.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Aug 26, 2015 at 12:59 AM, Jean-Michel Pichavant
<jeanmichel@sequans.com> wrote:
> To add to Joel's answer, the right side can be *any* sequence, and is not restricted to lists or tuples.
>
> a, b, c = (x for x in range(3)) # a generator for instance

FWIW, a generator is not a sequence; this works because the right side
can be any *iterable*, even more general than sequences.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [a,b,c,d] = 1,2,3,4 Chris Angelico <rosuav@gmail.com> - 2015-08-26 23:04 +1000

csiph-web