Python Principles
Python Q&A

How do I list all files in a directory?

Answer:

There are several ways to do this. You can use the listdir() built-in from the os module:

import os
filenames = os.listdir("directory/")

You can also use the glob module, which can be handy since it allows pattern matching:

import glob
filenames = glob.glob("directory/*.jpg")