Differences between revisions 2 and 3
Revision 2 as of 2023-03-01 14:43:18
Size: 2380
Comment:
Revision 3 as of 2023-03-01 14:44:56
Size: 2507
Comment:
Deletions are marked like this. Additions are marked like this.
Line 162: Line 162:
Takes one or more strings or `Path` objects.

{{{
from pathlib import Path
p = Path('.')

t = p.joinpath('temp')
}}}

Python Pathlib


Path

The Path class is instantiated like:

from pathlib import Path
p = Path('.')


Absolute


Anchor


As_Posix


As_Uri


ChMod


Drive


Exists


ExpandUser


Glob


Group



Is_Absolute


Is_Block_Device


Is_Char_Device


Is_Dir


Is_Fifo


Is_File


Is_Mount


Is_Relative_To


Is_Reserved


Is_Socket



IterDir


JoinPath

Takes one or more strings or Path objects.

from pathlib import Path
p = Path('.')

t = p.joinpath('temp')


Match


MkDir

from pathlib import Path
p = Path('.')

t = p.joinpath('temp')
t.mkdir(parents=False, exist_ok=True)


Name


Open


Owner


Parent


Parents


Parts


Read_Bytes


Read_Text



Relative_To


Rename


Replace


Resolve


RGlob


RmDir


Root


SameFile


Stat


Stem


Suffix


Suffixes



Touch



With_Name


With_Stem


With_Suffix


Write_Bytes


Write_Text


Cwd

A Path class method.

from pathlib import Path
c = Path.cwd()


Home

A Path class method.

from pathlib import Path
h = Path.home()


See also

Python pathlib module documentation


CategoryRicottone

Python/PathLib (last edited 2023-10-11 19:40:58 by DominicRicottone)