Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Monday, March 14, 2011

Splitting a Path to a list in Python

At work today I needed to split a file path into it's various directory and subdirectory components using Python. While the result of os.path.split can be inversed with os.path.join, they don't do what you might intuitively think they do. A cursory search on Google, while turning up various and sometimes overbuilt solutions, didn't give me a quick and dirty function to accomplish this task, so I wrote one myself.