Comments

: I've got a program which will eventually need to play a load of images from a directory in sequence for an animation.: : What I want to do is to read the filenames of all these images from the directory into a list so that I can then iterate over the list with something like [code]for x in thelistoffilenames. [/code]: : What's the best way to do this?: : Please help, many thanks.: : ITA: : "Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!":

Sorry, I've been foolish once again - I should have read the rest (or at least searched) the rest of the forum to find the answer before I posted!

Looking further down, I found the post on os.walk, and so I've found the solution to my problem.

Sorry for cluttering the board (mod delete this!)

ITA

"Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"

: I've got a program which will eventually need to play a load of images from a directory in sequence for an animation.: : What I want to do is to read the filenames of all these images from the directory into a list so that I can then iterate over the list with something like [code]for x in thelistoffilenames. [/code]: : What's the best way to do this?: : Please help, many thanks.: : ITA: : "Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"

I actually didn't know this off the top of my head, but figured there must be something available. Are you familiar with the dir() and help() built-in functions? They're quite handy in interactive mode for examining objects and reading the built-in documentation.

: Sorry, I've been foolish once again - I should have read the rest (or at least searched) the rest of the forum to find the answer before I posted!: : Looking further down, I found the post on os.walk, and so I've found the solution to my problem.

os.walk is great if you have a tree of directories to walk through. If you just need a list of files in a single known directory, os.listdir would be my choice.