Why does pathlib have both PurePath & Path?

First paragraph in pathlib documentation states:

Path classes are divided between pure paths, which provide purely computational operations without I/O, and concrete paths, which inherit from pure paths but also provide I/O operations.

Pure path objects provide path-handling operations which don’t actually access a filesystem.

Concrete paths are subclasses of the pure path classes. In addition to operations provided by the former(pure path), they also provide methods to do system calls on path objects.


In conclusion, PurePath acts like string (remove parts of path, join with another path, get parents etc). To remove directory, search directory, create a file or write to file, you must use Path object.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)