Home

A Better Way To List Files In A Directory In Python

This is the function to use:

_NOTE: This is still a draft in terms of the prose, but the code is tested and working. Still need to deal with hidden files though. Also need to set a flag to not go recursive_

Getting a list of files always feels like a pain. I wrote a JavaScript function a while ago to make it easier. It returns an array with details of the files.

I made a python version that does the same thing. The output look something like this:

That makes it easy to get to individual files by name or path, with or without extension.

Here's the code