pydoc > pathlib

📛 NAME

pathlib

🚀 Quick Reference

Use CaseCommandDescription
📂 Create a pathPath('some/path')Instantiate a path object (PosixPath or WindowsPath)
🏠 User home dirPath.home()Path to user's home directory
📁 Current working dirPath.cwd()Path to current working directory
🔗 Join pathspath / 'subdir' / 'file.txt'Combine with / operator
👆 Parent directorypath.parentLogical parent of the path
📝 Read textpath.read_text()Open file in text mode, read, and close
📝 Write textpath.write_text('hello')Open file in text mode, write, and close
📝 Read bytespath.read_bytes()Read file as bytes
📝 Write bytespath.write_bytes(data)Write bytes to file
✅ Exists?path.exists()Check whether path exists
📄 Is file?path.is_file()Check if regular file
📂 Is directory?path.is_dir()Check if directory
🔗 Is symlink?path.is_symlink()Check if symbolic link
📋 List directorypath.iterdir()Yield directory contents
🔍 Glob patternpath.glob('*.txt')Yield files matching pattern
🔍 Recursive globpath.rglob('*.py')Recursively yield matching files
📛 Suffixpath.suffixLast file extension (e.g. '.txt')
📛 Stempath.stemFilename without suffix
📛 Namepath.nameFinal path component
📌 Resolvepath.resolve()Absolute path, resolve symlinks
📌 Absolutepath.absolute()Absolute version (no normalization)
📌 Renamepath.rename('new')Rename file/directory
📌 Replacepath.replace('new')Rename, overwriting if exists
🗑️ Unlinkpath.unlink()Remove file or link
🗑️ Rmdirpath.rmdir()Remove empty directory
📁 Mkdirpath.mkdir(parents=True, exist_ok=True)Create directory
🖐️ Touchpath.touch()Create file (or update timestamp)
📊 Statpath.stat()Return file status information
🔐 Chmodpath.chmod(0o755)Change file permissions
👤 Ownerpath.owner()Return owner login name
👥 Grouppath.group()Return group name of file
🔗 Create symlinkpath.symlink_to(target)Make this path a symlink to target
🔗 Read symlinkpath.readlink()Return target of symlink
🔗 Hard linkpath.hardlink_to(target)Create hard link to target
📝 Change suffixpath.with_suffix('.new')Return new path with changed suffix
📝 Change namepath.with_name('new')Return new path with changed filename
📝 Change stempath.with_stem('new')Return new path with changed stem
🔗 Match patternpath.match('*.txt')Check if path matches glob pattern
📌 Relative topath.relative_to('/base')Compute relative path
📌 Is relative to?path.is_relative_to('/base')Check if path is relative to another
🌐 URIpath.as_uri()Return file:// URI
📟 Openpath.open('r')Open file (same as built-in open)

📚 MODULE REFERENCE

https://docs.python.org/3.10/library/pathlib.html

The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.

🏛️ CLASSES

builtins.object

📂 class Path(PurePath)

Path(*args, **kwargs)

PurePath subclass that can make system calls.

Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.

Method resolution order:

Path
PurePath
builtins.object

Methods defined here:

Class methods defined here:

Static methods defined here:

Methods inherited from PurePath:

Class methods inherited from PurePath:

Readonly properties inherited from PurePath:

🐧 class PosixPath(Path, PurePosixPath)

PosixPath(*args, **kwargs)

Path subclass for non-Windows systems. On a POSIX system, instantiating a Path should return this object.

Method resolution order:

PosixPath
Path
PurePosixPath
PurePath
builtins.object

Inherits all methods from Path and all methods and properties from PurePath (via PurePosixPath). No additional methods are defined.

🪟 class WindowsPath(Path, PureWindowsPath)

WindowsPath(*args, **kwargs)

Path subclass for Windows systems. On a Windows system, instantiating a Path should return this object.

Method resolution order:

WindowsPath
Path
PureWindowsPath
PurePath
builtins.object

Inherits all methods from Path and PurePath. Overrides:

📁 class PurePath(builtins.object)

PurePath(*args)

Base class for manipulating paths without I/O. PurePath represents a filesystem path and offers operations which don't imply any actual filesystem I/O. Depending on your system, instantiating a PurePath will return either a PurePosixPath or a PureWindowsPath object. You can also instantiate either of these classes directly, regardless of your system.

Methods defined here:

Class methods defined here:

Static methods defined here:

Readonly properties defined here:

🐧 class PurePosixPath(PurePath)

PurePosixPath(*args)

PurePath subclass for non-Windows systems. On a POSIX system, instantiating a PurePath should return this object. However, you can also instantiate it directly on any system.

Method resolution order:

PurePosixPath
PurePath
builtins.object

Inherits all methods, class methods, static methods, and readonly properties from PurePath. No additional members are defined.

🪟 class PureWindowsPath(PurePath)

PureWindowsPath(*args)

PurePath subclass for Windows systems. On a Windows system, instantiating a PurePath should return this object. However, you can also instantiate it directly on any system.

Method resolution order:

PureWindowsPath
PurePath
builtins.object

Inherits all methods, class methods, static methods, and readonly properties from PurePath. No additional members are defined.

📊 DATA

__all__ = ['PurePath', 'PurePosixPath', 'PureWindowsPath', 'Path', 'Po...

📄 FILE

/usr/lib/python3.10/pathlib.py

pathlib
📛 NAME 🚀 Quick Reference 📚 MODULE REFERENCE 🏛️ CLASSES
📂 class Path(PurePath) 🐧 class PosixPath(Path, PurePosixPath) 🪟 class WindowsPath(Path, PureWindowsPath) 📁 class PurePath(builtins.object) 🐧 class PurePosixPath(PurePath) 🪟 class PureWindowsPath(PurePath)
📊 DATA 📄 FILE

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 12:11 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^