Description

This module offers classes representing filesystem paths with semantics appropriate for different operating systems. 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.

Snippets

Get home directory

   1 from pathlib import Path
   2 p = Path.home()

Concatenate paths

   1 from pathlib import Path
   2 p = Path('/root') / 'subfolder' / 'second_subfolder/file.txt'

Get the directory the current script lives in

   1 from pathlib import Path
   2 p = Path(__file__).parent.absolute()

Howto/Python3/pathlib (last edited 2020-06-29 09:03:30 by Burathar)