October 27, 2025
pathlib.Path for cross-platform compatibilityLearning Objectives for Document Engineering
open and readopen() function with filename'r' parameterread() methodreadlines() methodwith statementwith context manager statement for automatic file closingread() methodreadlinesreadlines() to get list of lines inside of the filestrip() to removeopen and writeopen() function with write mode 'w''a' to add to existing fileswrite() methodwritelines() methodw mode'w' to create or overwrite files\na mode'a' to add content without overwritingpathlib!read_text() methodwrite_text() methodPath objects/ operator to join path components naturallywrite_text() and read_text() methods simplify file operationsglobglob() method to find files matching patternsstat() methodjson module from standard libraryjson.load() to read JSON from file objectjson.load() to parse JSON data into dictionaries and listsdoc_metadata.json file inside of the repositorysets to automatically eliminate duplicatesdoc_metadata.json{
"D001": {
"category": "tutorial",
"difficulty": "beginner"
},
"D002": {
"category": "tutorial",
"difficulty": "advanced"
},
"D003": {
"category": "reference",
"difficulty": "intermediate"
},
"D004": {
"category": "guide",
"difficulty": "beginner"
},
"D005": {
"category": "tutorial",
"difficulty": "intermediate"
}
}json.dump() to write to file objectsjson.dumps() to create JSON stringssummary variable as a dict in Pythondoc_summary.jsonopen() with context managerspathlib.Path for platform-independent file handlingProsegrammers