Elektrine lite

← Feed

@treyhunner@mastodon.social

Post #1065481

2026-04-07 17:43 UTC

Python Tip #97 (of 365): When you need to read/write a whole file all at once, use the appropriate pathlib.Path helper method Instead of: with open(path) as file: contents = file.‍read() Do this: contents = path.‍read_text() And instead of: with open(path, mode="wt") as file: file.write(contents) Do this: path.write_text(contents) #Python #DailyPythonTip

Replies (0)

No replies.