Obtenha o nome de um arquivo usando OS
>>> list_of_names_in_directory = os.listdir('path/of/directory')
OCD Code Flipper
>>> list_of_names_in_directory = os.listdir('path/of/directory')
>>> f = open('/tmp/generic.png','r')
>>> f.name
'/tmp/generic.png'
>>> import os
>>> os.path.basename(f.name)
'generic.png'