pylint-bot / pylint-unofficial

UNOFFICIAL playground for pylint github migration
0 stars 0 forks source link

Checker for "for line in f.readlines():" #696

Open pylint-bot opened 9 years ago

pylint-bot commented 9 years ago

Originally reported by: Florian Bruhin (BitBucket: The-Compiler, GitHub: @The-Compiler?)


When iterating over a file, for line in f: should be used rather than for line in f.readlines():.

I see beginners make this mistake often, and I even did it myself in less obvious contexts [line.strip() for line in f.readlines()] instead of [line.strip() for line in f].


pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Sounds useful!