Last active
April 18, 2024 14:19
-
-
Save horvatha/4cb628d8201e569df689e08e50649e7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fnmatch | |
import os | |
import sys | |
from pathlib import Path | |
eleresi_ut = Path.home() / "Documents" | |
minta = 'Co*t*.*' | |
# good old walk | |
for root, dirs, files in os.walk(eleresi_ut): | |
for filename in fnmatch.filter(files, minta): | |
print(root + filename) | |
# pathlib's walk | |
major, minor = sys.version_info[:2] | |
if (major, minor) >= (3, 12): | |
print("Yeah. Once again.") | |
for root, dirs, files in eleresi_ut.walk(): | |
for filename in fnmatch.filter(files, minta): | |
print(root / filename) | |
else: | |
print("Second version needs Python 3.12+") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment