DEV Community

Discussion on: Mastering Python: 6 Sneaky Tips Every Developer Should Know

Collapse
 
manhdt profile image
thitkhotau

To read/ write a file, I prefer using pathlibs with Path(file).read_text(...) without context managers rather than using with open("file.txt", "r"). I see it is shorter, OOP than, but I don't see other advantages.