import os
for name in os.listdir("."):
if os.path.isdir(name):
print(str(name))
from os import listdir
from os.path import isfile, join
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
# Basic syntax:
import os
os.path.dirname('/path/to/your/favorite/file.txt')
--> '/path/to/your/favorite/'
mylist = [f for f in glob.glob("*.txt")]