Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95658
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: [a,b,c,d] = 1,2,3,4 |
| Date | 2015-08-26 11:16 -0400 |
| References | <CAPM-O+y-FftPRv7_VqSG6JVp3ocr__yd=RuppLh5ZWcMg25v+g@mail.gmail.com> <935842626.955183.1440514765199.JavaMail.root@sequans.com> <20150826072134.03ed9e71@bigbox.christie.dr> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.49.1440602243.11709.python-list@python.org> (permalink) |
On 8/26/2015 8:21 AM, Tim Chase wrote: >> a, b, c = (x for x in range(3)) # a generator for instance > > Since range() *is* a generator, why not just use In Python 3, range is a sequence class with a separate iterator class >>> r = range(3) >>> r range(0, 3) >>> iter(r) <range_iterator object at 0x00000000034682D0> Like all sequences, a range object can be iterated multiple times as a new iterator is used each time. >>> list(r) [0, 1, 2] >>> list(r) [0, 1, 2] -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: [a,b,c,d] = 1,2,3,4 Terry Reedy <tjreedy@udel.edu> - 2015-08-26 11:16 -0400
csiph-web