Skip to content

Commit 89c01c0

Browse files
bites 116 - os and glob
1 parent 75cd5e0 commit 89c01c0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

116/files.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import glob
1+
from glob import glob
22
import os
33

44
ONE_KB = 1024
55

66

77
def get_files(dirname, size_in_kb):
88
"""Return files in dirname that are >= size_in_kb"""
9-
file_list = os.listdir(dirname)
10-
return sorted([file for file in file_list if os.path.getsize(file) >= size_in_kb])
11-
12-
13-
print(get_files(".", ONE_KB))
9+
glob_pattern = os.path.join(dirname, '*')
10+
return [file for file in glob(dirname+"*") if os.path.getsize(file) >= ONE_KB*size_in_kb]

0 commit comments

Comments
 (0)