Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « pathlib » Python 3.11.3

Classe « Path »

Informations générales

Héritage

builtins.object
    PurePath
        Path

Définition

class Path(PurePath):

help(Path)

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.
    

Constructeur(s)

Signature du constructeur Description
__new__(cls, *args, **kwargs)
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__]

Liste des propriétés

Nom de la propriétéDescription
anchorThe concatenation of the drive and root, or ''. [extrait de __doc__]
driveThe drive prefix (letter or UNC path), if any. [extrait de __doc__]
nameThe final path component, if any. [extrait de __doc__]
parentThe logical parent of the path. [extrait de __doc__]
parentsA sequence of this path's logical parents. [extrait de __doc__]
partsAn object providing sequence-like access to the [extrait de __doc__]
rootThe root of the path, if any. [extrait de __doc__]
stemThe final path component, minus its last suffix. [extrait de __doc__]
suffix
suffixes

Liste des opérateurs

Opérateurs hérités de la classe PurePath

__eq__, __ge__, __gt__, __le__, __lt__, __rtruediv__, __truediv__

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__enter__(self)
__exit__(self, t, v, tb)
absolute(self) Return an absolute version of this path by prepending the current [extrait de absolute.__doc__]
chmod(self, mode, *, follow_symlinks=True)
cwd() Return a new path pointing to the current working directory [extrait de cwd.__doc__]
exists(self)
expanduser(self) Return a new path with expanded ~ and ~user constructs [extrait de expanduser.__doc__]
glob(self, pattern) Iterate over this subtree and yield all existing files (of any [extrait de glob.__doc__]
group(self)
hardlink_to(self, target)
home() Return a new path pointing to the user's home directory (as [extrait de home.__doc__]
is_block_device(self)
is_char_device(self)
is_dir(self)
is_fifo(self)
is_file(self)
is_mount(self)
is_socket(self)
is_symlink(self)
iterdir(self) Iterate over the files in this directory. Does not yield any [extrait de iterdir.__doc__]
lchmod(self, mode)
link_to(self, target)
lstat(self)
mkdir(self, mode=511, parents=False, exist_ok=False)
open(self, mode='r', buffering=-1, encoding=None, errors=None, newline=None)
owner(self)
read_bytes(self)
read_text(self, encoding=None, errors=None)
readlink(self)
rename(self, target)
replace(self, target)
resolve(self, strict=False)
rglob(self, pattern) Recursively yield all existing files (of any kind, including [extrait de rglob.__doc__]
rmdir(self)
samefile(self, other_path) Return whether other_path is the same or not as this file [extrait de samefile.__doc__]
stat(self, *, follow_symlinks=True)
symlink_to(self, target, target_is_directory=False)
touch(self, mode=438, exist_ok=True)
unlink(self, missing_ok=False)
write_bytes(self, data)
write_text(self, data, encoding=None, errors=None, newline=None)

Méthodes héritées de la classe PurePath

__bytes__, __fspath__, __hash__, __init_subclass__, __reduce__, __repr__, __str__, __subclasshook__, as_posix, as_uri, is_absolute, is_relative_to, is_reserved, joinpath, match, relative_to, with_name, with_stem, with_suffix

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__