A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-April/023716.html below:

Fw: [Python-Dev] Use for enumerate()

Fw: [Python-Dev] Use for enumerate() Fw: [Python-Dev] Use for enumerate()Raymond Hettinger python@rcn.com
Sat, 27 Apr 2002 13:20:59 -0400
> > > > Challenge 3: do it faster and with less code.
> > it should work even if the file is too large
> > to fit in memory (as long as each individual line fits in memory).

def getline(filename, lineno):
    if lineno < 1:
        return ''
    f = open(filename)
    g = f.readline
    return (reduce(lambda x,y: g(), range(lineno), ''), f.close())[0]


This incorporates a couple of ideas inspired by Tim's post.


Raymond Hettinger






RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4