diff --git a/pipreqs/pipreqs.py b/pipreqs/pipreqs.py index 3d4afa0..c8f8d6d 100755 --- a/pipreqs/pipreqs.py +++ b/pipreqs/pipreqs.py @@ -33,8 +33,8 @@ def get_all_imports(start_path): logging.debug('Traversing tree, start: %s', start_path) for root, dirs, files in os.walk(start_path): packages.append(os.path.basename(root)) - files = filter(lambda fn:os.path.splitext(fn)[1] == ".py", files) - packages += map(lambda fn:os.path.splitext(fn)[0], files) + files = [fn for fn in files if os.path.splitext(fn)[1] == ".py"] + packages += [os.path.splitext(fn)[0] for fn in files] for file_name in files: with open(os.path.join(root, file_name), "r") as file_object: lines = filter(lambda l:len(l) > 0, map(lambda l:l.strip(), file_object))