© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
A. DanialPython for MATLAB Developmenthttps://doi.org/10.1007/978-1-4842-7223-7_8

8. Interacting with the File System

Albert Danial1  
(1)
Redondo Beach, CA, USA
 

A program that reads or writes files must sometimes interact with the file system in other ways, for example, checking whether or not a file or directory exists, seeing if a file can be read or written to, getting file size or modification time, reading a directory’s contents, and so on.

The primary modules for working with the file system in Python include os, os.path, and pathlib. My preference is pathlib, the newest of the three, because its Path() function returns file path objects that can read, ...

Get Python for MATLAB Development: Extend MATLAB with 300,000+ Modules from the Python Package Index now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.