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/023712.html below:

[Python-Dev] Use for enumerate()

[Python-Dev] Use for enumerate() [Python-Dev] Use for enumerate()Raymond Hettinger python@rcn.com
Sat, 27 Apr 2002 12:52:08 -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):    # Second attempt
    if lineno < 1:
        return ''
    f = open(filename)
    reduce(lambda x,y: f.readline(), xrange(lineno-1), None)
    return (f.readline(), f.close())[0]


Arghh, must resist lambda.
Must not use reduce.
Must avoid tuple tricks.
...
GvR's code is too powerful
I can't resist

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