Hi @dgobbi, thanks for your reply.
It’s a built-in Python module that helps with path handling. It was introduced in Python 3.4, for which VTK has support, so it’s indirectly related to VTK through the Python wrappers. It wouldn’t solve VTK-related problems, but it would improve Python support.
This is an example form the Slicer forum before and after using pathlib
:
import os
myDir = '/tmp/images'
for root, dirs, files in os.walk(myDir, topdown=False):
for name in files:
_, ext = os.splitext(name)
if ext == '.nrrd':
loadVolume(os.path.join(root, name))
from pathlib import Path
myDir = Path('/tmp/images')
for file in myDir.glob('**/*.nrrd'):
loadVolume(str(file)) # need str until pathlib is supported
Here are some large Python libraries getting adapted to pathlib
:
nibabel
(23/10/2019)
pandas
(10/9/2015)
numpy
(6/10/2015)
Pillow
(3/8/2015)
matplotlib
(18/7/2016)
Related Python Enhancement Proposals (PEP):
PEP 428 – The pathlib module – object-oriented filesystem paths
PEP 519 – Adding a file system path protocol
Some more context on the advantages of pathlib
: https://realpython.com/python-pathlib/#the-problem-with-python-file-path-handling
I hope that makes sense and is a bit more clear than my previous post.