> > > 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