Improve listdir.

This commit is contained in:
Darko Poljak 2017-07-06 17:22:25 +02:00
parent 80c3dd7572
commit f9b632eebb

View file

@ -26,7 +26,10 @@ def listdir(path='.', include_dot=False):
"""os.listdir but do not include entries whose names begin with a dot('.') """os.listdir but do not include entries whose names begin with a dot('.')
if include_dot is False. if include_dot is False.
""" """
return [x for x in os.listdir(path) if include_dot or not _ishidden(x)] if include_dot:
return os.listdir(path)
else:
return [x for x in os.listdir(path) if not _ishidden(x)]
def _ishidden(path): def _ishidden(path):