GitHub
github.com › python › cpython › blob › main › Lib › posixpath.py
cpython/Lib/posixpath.py at main · python/cpython
The Python programming language. Contribute to python/cpython development by creating an account on GitHub.
O'Reilly
oreilly.com › library › view › python-standard-library › 0596000960 › ch13s04.html
The posixpath Module - Python Standard Library [Book]
May 10, 2001 - File: posixpath-example-1.py import posixpath file = "/my/little/pony" print "isabs", "=>", posixpath.isabs(file) print "dirname", "=>", posixpath.dirname(file) print "basename", "=>", posixpath.basename(file) print "normpath", "=>", posixpath.normpath(file) print "split", "=>", posixpath.split(file) print "join", "=>", posixpath.join(file, "zorba") isabs => 1 dirname => /my/little basename => pony normpath => /my/little/pony split => ('/my/little', 'pony') join => /my/little/pony/zorba
Author: Fredrik Lundh
Published: 2001
Pages: 304
Python
docs.python.org › 3 › library › pathlib.html
pathlib — Object-oriented filesystem paths
>>> import os >>> os.name 'posix' >>> Path('setup.py') PosixPath('setup.py') >>> PosixPath('setup.py') PosixPath('setup.py') >>> WindowsPath('setup.py') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pathlib.py", line 798, in __new__ % (cls.__name__,)) UnsupportedOperation: cannot instantiate 'WindowsPath' on your system · Some concrete path methods can raise an OSError if a system call fails (for example because the path doesn’t exist).
Sunysb
max2.physics.sunysb.edu › itp › computing › doc › python › python-texinfo › posixpath.html
posixpath -- Python library reference
Return the base name of pathname p. This is the second half of the pair returned by posixpath.split(p).
ProgramCreek
programcreek.com › python › example › 88270 › pathlib.PosixPath
Python Examples of pathlib.PosixPath
def _make_child(self, args: Iterable[str]): if not self.bucket: bucket, *rest_args = args bucket = bucket.lstrip("/") bucket, *rest_parts = PosixPath(bucket).parts return self.with_bucket(bucket)._make_child(rest_parts + rest_args) parts = [p for p in self._key_parts] for item in args: if not isinstance(item, str): raise ValueError("child must be string") item = item.lstrip("/") # remove leading '/' if not item: raise ValueError("child must not be empty") for p in PosixPath(item).parts: parts.append(p) return self._create(self._client, self.bucket, tuple(parts))
Basicexamples
basicexamples.com › example › python › pathlib-posixpath
Basic example of pathlib.PosixPath in Python
from pathlib import PosixPath # Creating a PosixPath object path = PosixPath('/path/to/file.txt') # Checking if the path exists if path.exists(): print(f"The path {path} exists.") else: print(f"The path {path} does not exist.") # Getting the file name from the path filename = path.name print(f"The ...
Medium
dzdata.medium.com › pathlib-a-better-way-to-work-with-paths-in-python-4f24dea14fab
pathlib — a Better Way to Work with Paths in Python | by Dor Zvulun | Medium
July 19, 2023 - If you look closely at the previous example, you see that we didn’t get a Path object, but PosixPath . The Path class let us keep our code platform-independent, meaning it will work on both Windows and Unix-based platforms. In a Unix-based platform such as Ubuntu and MacOS the Path class returns a PosixPath object, while on Windows it returns WindowsPath .
Acid & Base
sceweb.sce.uhcl.edu › helm › WEBPAGE-Python › documentation › python_tutorial › lib › module-posixpath.html
8.2 posixpath -- Common POSIX pathname manipulations.
Return the base name of pathname p. This is the second half of the pair returned by posixpath.split(p).
freeCodeCamp
freecodecamp.org › news › how-to-use-pathlib-module-in-python
Python Path – How to Use the Pathlib Module with Examples
May 10, 2022 - Since the concrete path is the subclass of the pure path, you can do everything with concrete paths using the PurePath() properties. This means that we can use, for example, the .with_suffix property to add a suffix to a concrete path: In [*]: p = pathlib.Path('/src/goo/scripts/main') p.with_suffix('.py') Out[*]: PosixPath('/src/goo/scripts/main.py')
GeeksforGeeks
geeksforgeeks.org › python › pathlib-module-in-python
Pathlib Module in Python - GeeksforGeeks
It provides methods for UNIX-specific filesystem interaction. Example: This code imports PosixPath class and creates a concrete path object using PosixPath('/usr/local/bin') which represents a Unix-style file system path.
Published: June 15, 2026
Python
docs.python.org › 3.4 › library › pathlib.html
11.1. pathlib — Object-oriented filesystem paths — Python 3.4.10 documentation
June 16, 2019 - >>> import os >>> os.name 'posix' >>> Path('setup.py') PosixPath('setup.py') >>> PosixPath('setup.py') PosixPath('setup.py') >>> WindowsPath('setup.py') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pathlib.py", line 798, in __new__ % (cls.__name__,)) NotImplementedError: cannot instantiate 'WindowsPath' on your system · Concrete paths provide the following methods in addition to pure paths methods. Many of these methods can raise an OSError if a system call fails (for example because the path doesn’t exist): classmethod Path.cwd()¶ ·