Search code examples
pythonreadlinereadlines

readline and readlines methods missing from python 3.2?


Did they remove file.readline() and file.readlines() from python 3.2? If yes what did they replace it with?


Solution

  • While there is no file type any more in Python 3.x, the various types in the io module that replace the old file type still support f.readline() and f.readlines(). You actually don't need those methods, though, since they can be substituted by next(f) and list(f).