os.listdir() (all files in a directory)

Returns the files of the specified directory.

In [1]: import os
In [2]: os.listdir('.')
Out[2]: 
['.Spectra_misc.pl',
 'nxTest.py~',
 'nxTest.py',
 'fio2h5.py~',
...]

Another example:

#!/usr/bin/env python
import os

for file in os.listdir( "/home/user/temp"):
    if file.endswith( ".py"):
        print( "file", file)

And another example:

import os
path = '.'
files = [ f for f in os.listdir(path) if os.path.isfile(os.path.join(path,f)) ]