Hacker News new | ask | show | jobs
by 7thaccount 544 days ago
There were several Python versions shown at the link and the latter one that I was referring to does not read it all into memory. It loops through each line in only three lines of code, not like 1/4 of a page.

I tried just pasting the code into the window, but never learned how to format HN on mobile. Sorry for the confusion. After the colon there are indents, so 3 separate lines.

with open('testfile.txt') as f: for line in f: print(line.strip())

1 comments

I think Haskell seems harder because it's built on another set of abstractions (laziness, typeclasses) where Python abstractions (iterators in this case, plus the with statement for resource acquisition/cleanup) are more common, but I could be wrong (I've been working with Scala for close to a decade now so functional style looks more familiar that imperative now.)

(I also always forget how to format comments, the ref is here: https://news.ycombinator.com/formatdoc )