Jan-12-2018, 10:38 PM
Path (of pathlib) instantiates a concrete path for the platform the code is running on.
This means both purepaths (purely computational operations) and Concrete ( which inherit from pure paths but also provide I/O operations)
I have been using pathlib almost exclusively for about two months now, and really like how clean it is.
Since it is 100% object oriented, you can do things like:
This means both purepaths (purely computational operations) and Concrete ( which inherit from pure paths but also provide I/O operations)
I have been using pathlib almost exclusively for about two months now, and really like how clean it is.
Since it is 100% object oriented, you can do things like:
from pathlib import Path home = Path('.') datapath = home / 'data' jsonpath = datapath / 'json' >>> imagepath = home / '..' / 'images' >>> image_list = [x for x in imagepath.iterdir()] >>> for image in image_list: ... print(image) ... ..\images\advancedsplash.png ..\images\AG00028_.gif ..\images\AG00039_.gif ..\images\AG00178_.gif ..\images\AG00183_.gif ..\images\AG00185_.gif ..\images\aquabutton.png ..\images\aquachecked.ico ..\images\aquaflagged.ico ..\images\aquanotchecked.ico >>>>>> imagepath.resolve() WindowsPath('Z:/python/q-t/r/RfcViewerJupyterVenv/RfcViewerJupyter/images') >>>