Describe the bug, what's wrong, and what you expect:
Python's standard library has a pathlib module that acts as a OS agnostic method of manipulating paths. I quite like it and many libraries support it as a replacement input for strings when file paths are requested. At least pyvista.UnstructuredGrid() does not support pathlib objects, though I'd imagine even more do.
To add flexibility (and increase the "pythonic"ness of the library), it might be worth also adding support for other python file-type objects. See code in numpy.loadfile and it's supporting function isfileobj.
I'd imagine this would need to be implemented in _load_file.
To Reproduce
import pyvista as pv
from pathlib import Path
vtuFilePath = Path(r'./test.vtu')
pv.UnstructuredGrid(vtuFilePath)
# Errors with 'TypeError: Cannot work with input type <class 'pathlib.PosixPath'>'
Describe the bug, what's wrong, and what you expect:
Python's standard library has a
pathlibmodule that acts as a OS agnostic method of manipulating paths. I quite like it and many libraries support it as a replacement input for strings when file paths are requested. At leastpyvista.UnstructuredGrid()does not support pathlib objects, though I'd imagine even more do.To add flexibility (and increase the "pythonic"ness of the library), it might be worth also adding support for other python file-type objects. See code in
numpy.loadfileand it's supporting functionisfileobj.I'd imagine this would need to be implemented in
_load_file.To Reproduce