I'm trying to iterate over all directories (not recursively) inside a given directory. I have this file structure:
debian/
dev-requirements.txt
MANIFEST.in
mypy.ini
pytest.ini
README.md
requirements.txt
resources/
reviewer/
setup.py*
tests/
tox.ini
If i use glob.glob
, it's yielding the correct results:
>>> import glob
>>> import os
>>> glob.glob(f'*{os.path.sep}')
['reviewer/', 'debian/', 'resources/', 'tests/']
But with Path.glob
it's yiedling different results for the same pattern:
>>> from pathlib import Path
>>> [e.name for e in Path().glob(f'*{os.path.sep}')]
['reviewer', 'debian', '.coveragerc', '.gitignore', '.mypy_cache', '.venv', 'dev-requirements.txt', 'MANIFEST.in', 'tox.ini', 'setup.py', '.git', 'mypy.ini', '.idea', '.tox', 'resources', '.pyreview.ini', 'README.md', 'pytest.ini', '.coverage', 'requirements.txt', '.pytest_cache', 'tests']
Shouldn't both operations be equivalent? I know there are other ways to do what I'm trying to do, that's not my question; I want to know why are both operations yielding different results for the same glob pattern.
EDIT: same question was answered here