iter with stepsize

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan G Isaac

    iter with stepsize

    If I have a sequence, I can get every other or every fifth
    element by slicing. Is there an equivalent for iterators?

    More specifically, I want every fifth line of a big file.
    What is the most efficient way to get them?

    Thanks,
    Alan Isaac
  • Paul Rubin

    #2
    Re: iter with stepsize

    Alan G Isaac <alan.isaac@gma il.comwrites:
    If I have a sequence, I can get every other or every fifth
    element by slicing. Is there an equivalent for iterators?
    itertools.islic e

    Comment

    • Alan G Isaac

      #3
      Re: iter with stepsize

      Alan G Isaac <alan.isaac@gma il.comwrites:
      >If I have a sequence, I can get every other or every fifth
      >element by slicing. Is there an equivalent for iterators?

      On 10/15/2008 11:12 PM Paul Rubin apparently wrote:
      itertools.islic e

      Oh, of course.
      I'm a bit embarrassed not to have thought
      to look at itertools before posting.
      Thanks!
      Alan

      Comment

      Working...