Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    This is a bad approach. For one thing, calling .read().splitlines() isn't in any way "simpler" than just calling .readlines(). For another, it's memory-inefficient; you're needlessly storing two versions of the file content (the single string returned by .read(), and the list of strings returned by splitlines()) in memory at once. Commented Dec 29, 2019 at 14:12
  • @MarkAmery True. Thanks for highlighting this. I have updated my answer. Commented Dec 31, 2019 at 10:00