If I'm given a path as a string, such as "~/pythoncode/*.py" what is the best way to glob it in pathlib
?
Using pathlib, there is a way of appending to a path using a glob:
p = pathlib.Path('~/pythoncode/').expanduser().glob('*.py')
but this, for example, does not work because the user isn't expanded:
p = pathlib.Path().glob('~/pythoncode/*.py')
and this is generates an exception because I'm providing no arguments to glob()
:
p = pathlib.Path('~/pythoncode/*.py').expanduser().glob()
Is there a way to do this in pathlib
, or must I parse the string first?