readline and readlines methods missing from python 3.2?

nik picture nik · Jun 5, 2011 · Viewed 8.2k times · Source

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

Answer

Sven Marnach picture Sven Marnach · Jun 5, 2011

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