Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40905
| From | Skip Montanaro <skip@pobox.com> |
|---|---|
| Subject | Re: itertools doc example "consume" |
| Date | 2013-03-08 21:43 +0000 |
| References | <CANc-5UxWmbhgwNpx195KO8j3HvDEPa8shdzF1fxOhWB2mxYT-Q@mail.gmail.com> <CALwzidmp=PZAuTJTq5uAsLeMdiQhFonZ3zYY4DH3UmOLedpvOQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3102.1362779016.2939.python-list@python.org> (permalink) |
Ian Kelly <ian.g.kelly <at> gmail.com> writes: > Depending on your Python version lst is either a range object or a > list, neither of which is an iterator. If you pass to consume an > iterable object that is not an iterator, it will implicitly obtain an > iterator for it, consume from the iterator, and then discard the > iterator, with no effect on the original object. > > In general the itertools functions will work equally well on iterators > and other iterables, but consume is special in that what it does is > only relevant to iterators. Thanks for the explanation. I clearly still need to grapple with this stuff a bit... Skip
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: itertools doc example "consume" Skip Montanaro <skip@pobox.com> - 2013-03-08 21:43 +0000
csiph-web