pathlib.Path.replace()

Path.replace(target) Rename this file or directory to the given target. If target points to an existing file or directory, it will be unconditionally replaced.

pathlib.Path.rename()

Path.rename(target) Rename this file or directory to the given target. On Unix, if target exists and is a file, it will be replaced silently if the user has permission. target can be either a string or another path object: >>> p = Path('foo') >>> p.open('w').write('some text') 9 >>> target = Path('bar') >>> p.rename(target) >>> target.open().read() 'some text'

pathlib.Path.read_text()

Path.read_text(encoding=None, errors=None) Return the decoded contents of the pointed-to file as a string: >>> p = Path('my_text_file') >>> p.write_text('Text file contents') 18 >>> p.read_text() 'Text file contents' The optional parameters have the same meaning as in open(). New in version 3.5.

pathlib.Path.read_bytes()

Path.read_bytes() Return the binary contents of the pointed-to file as a bytes object: >>> p = Path('my_binary_file') >>> p.write_bytes(b'Binary file contents') 20 >>> p.read_bytes() b'Binary file contents' New in version 3.5.

pathlib.Path.owner()

Path.owner() Return the name of the user owning the file. KeyError is raised if the file’s uid isn’t found in the system database.

pathlib.Path.open()

Path.open(mode='r', buffering=-1, encoding=None, errors=None, newline=None) Open the file pointed to by the path, like the built-in open() function does: >>> p = Path('setup.py') >>> with p.open() as f: ... f.readline() ... '#!/usr/bin/env python3\n'

pathlib.Path.mkdir()

Path.mkdir(mode=0o777, parents=False, exist_ok=False) Create a new directory at this given path. If mode is given, it is combined with the process’ umask value to determine the file mode and access flags. If the path already exists, FileExistsError is raised. If parents is true, any missing parents of this path are created as needed; they are created with the default permissions without taking mode into account (mimicking the POSIX mkdir -p command). If parents is false (the default), a miss

pathlib.Path.lstat()

Path.lstat() Like Path.stat() but, if the path points to a symbolic link, return the symbolic link’s information rather than its target’s.

pathlib.Path.lchmod()

Path.lchmod(mode) Like Path.chmod() but, if the path points to a symbolic link, the symbolic link’s mode is changed rather than its target’s.

pathlib.Path.iterdir()

Path.iterdir() When the path points to a directory, yield path objects of the directory contents: >>> p = Path('docs') >>> for child in p.iterdir(): child ... PosixPath('docs/conf.py') PosixPath('docs/_templates') PosixPath('docs/make.bat') PosixPath('docs/index.rst') PosixPath('docs/_build') PosixPath('docs/_static') PosixPath('docs/Makefile')