On this page
pathlib.UnsupportedOperation
Prev: pathlib.PureWindowsPath | Up: pathlib | Next: pathlib.WindowsPath
Rel: pathlib.Path, pathlib.PosixPath, pathlib.PurePath, pathlib.PurePosixPath
Ref: docs.python.org โ pathlib.UnsupportedOperation
Tags: #public #python3 #stdlib #pathlib
Import
import pathlib
from pathlib import UnsupportedOperation
Signature & Overview
pathlib.UnsupportedOperation(...)
An exception that is raised when an unsupported operation is attempted.
Methods & Attributes
UnsupportedOperation.add_note(self, note, /)โ Add a note to the exceptionUnsupportedOperation.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import os
from pathlib import UnsupportedOperation, WindowsPath
# Raised when instantiating a concrete path for a different OS
if os.name == "posix":
try:
WindowsPath("C:/temp")
except UnsupportedOperation as exc:
assert "WindowsPath" in str(exc)
Gotchas
- Python 3.13+ exception: Earlier Python versions raised
NotImplementedErrorwhen constructingWindowsPathon POSIX (orPosixPathon Windows);UnsupportedOperationinherits fromNotImplementedErrorfor backwards compatibility. - Fix by using
Pure*Path: Switch toPureWindowsPathorPurePosixPathwhenever you only need path parsing without OS syscalls.
REPL Inspect
from pathlib import UnsupportedOperation
help(UnsupportedOperation)
Linked from
Related notes
- tuts/python3/stdlib_module/pathlib/PureWindowsPath Linked here; links to this page; shared tags: #pathlib, #stdlib
- tuts/python3/stdlib_module/pathlib/WindowsPath Linked here; links to this page; shared tags: #pathlib, #stdlib
- tuts/python3/stdlib_module/pathlib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/pathlib/Path Linked here; shared tags: #pathlib, #stdlib
- tuts/python3/stdlib_module/pathlib/PosixPath Linked here; shared tags: #pathlib, #stdlib
- tuts/python3/stdlib_module/pathlib/PurePath Linked here; shared tags: #pathlib, #stdlib
- tuts/python3/stdlib_module/pathlib/PurePosixPath Linked here; shared tags: #pathlib, #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib