🌐
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).
🌐
GeeksforGeeks
geeksforgeeks.org › python › posixpath-module-in-python
Posixpath Module in Python - GeeksforGeeks
September 27, 2023 - import posixpath # This program combines two paths: `&quot;/path/to/dir&quot;` and `&quot;file.txt&quot;` using the `posixpath.join` function. path1 = &quot;/path/to/dir&quot; path2 = &quot;file.txt&quot; # It's like putting together a folder ...
🌐
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).
🌐
Note.nkmk.me
note.nkmk.me › home › python
How to Use pathlib in Python | note.nkmk.me
February 9, 2024 - As shown in the examples so far, outputting a Path object with print() displays the path as a string, but its type is still Path (PosixPath or WindowsPath), not a string (str).
🌐
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 ...
🌐
Real Python
realpython.com › python-pathlib
Python's pathlib Module: Taming the File System – Real Python
4 days ago - It’s possible to ask for a WindowsPath or a PosixPath explicitly, but you’ll only be limiting your code to that system without gaining any benefits.
🌐
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 .
Find elsewhere
🌐
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
🌐
Switowski
switowski.com › blog › pathlib
Pathlib for Path Manipulations - Sebastian Witowski
July 17, 2023 - And I love this object-oriented approach to file paths. It makes writing scripts for filesystem manipulation much more fun, making Python an even better replacement for bash scripts[1]. You can find all the code examples from this article in my blog-resources repository.
🌐
GitHub
github.com › enthought › Python-2.7.3 › blob › master › Lib › posixpath.py
Python-2.7.3/Lib/posixpath.py at master · enthought/Python-2.7.3
Default Repo description from terraform module. Contribute to enthought/Python-2.7.3 development by creating an account on GitHub.
Author: enthought
🌐
Practical Business Python
pbpython.com › pathlib-intro.html
Using Python’s Pathlib Module - Practical Business Python
One of python’s strengths is that it continues to develop and grow over time. The pathlib module is a prime example of the care that the maintainers take to build new capabilities that improve the overall capabilities of python.
🌐
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()¶ ·