os.listdir() returns everything inside a directory — including both files and directories.
isfile() can be used to only list files:
from os import listdir from os.path import isfile, join onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
os.walk() yields two lists for each directory it visits — one for files and one for dirs. If you only want the top directory you can break the first time it yields:
from os import walk f =  for (dirpath, dirnames, filenames) in walk(mypath): f.extend(filenames) break
from os import walk filenames = next(walk(mypath), (None, None, )) #  if no file