{"id":18,"description":"Python - using pathlib for quick actions with files","tags":["python","programming","io"],"contents":["# for simple actions like opening a file and just reading some text","# or writing few lines of text in a string, pathlib.Path can be a great option","# it abstracts away the usual workflow of opening a file, writing and closing","# into convenient functions","\u003e\u003e\u003e from pathlib import Path","\u003e\u003e\u003e myfile = Path(\"foobar.txt\")","\u003e\u003e\u003e myfile.write_text(\"foobar\")","6","\u003e\u003e\u003e myfile.read_text()","'foobar'"]}
