We are moving from the Basic.md
import Basic
- Python Standard Library, status:watch
- Working with paths:
from pathlib import Path
, Path class helps us create path object, combination is possiblePath() / Path("ecommerce/file.py")
, We get a lot of useful methods - Working directories: we are still working with the
Path
class, we can make dir and remove dir, rename dir,Path().iterdir()
is a generator, Pathlib is a must read again - working with files: access the file with the pathlib module with all his files, we can work with files,
Path().read_text() or .write_text() or write_bytes()
instead ofopen()
, make a copy with the moduleshutil
,time
module to work with time object - Working with zip files:
from Zipfile import Zipfile
, with as syntax is better, we still the pathlib module to access the files with a path object, you can build a script to read or write - Working with csv files:
import csv
, combine with thewith open("ok.csv","r or w") as file: <action>
The documentation is avalaible on python.org
This module offers classes representing filesystem paths with semantics appropriate for different operating systems. Path classes are divided between pure paths, which provide purely computational operations without I/O, and concrete paths, which inherit from pure paths but also provide I/O operations.
documentation is on python.org
pythoncore/standardtopic/files/file.py
is a perfect example of copying around some file content using several python built-in libraries