Tom Ritchford
Apr 5, 2024

--

Everything you write is correct, but also, really old-school. ๐Ÿ˜€

98 times out of 100, when you're doing file and path manipulation, you should be using pathlib!

For example, to print all .txt files below a given directory, use pathlib.Path.glob:

from pathlib import Path

print(*Path('folder1').glob('**/.txt'))

--

--

Tom Ritchford
Tom Ritchford

Responses (1)