I worked out one of the reasons my nasty little function is bad:
if '/' in sPath: ... month = [sPath.split('/') for x in range(len(days))]
sPath was built by walking down into a directory and I used it to work out if I was looking at directories for days or months. This little fragment of code worked fine, until today, when I was running it on my Windows machine.
Windows uses the \ character to separate directories, Python knows this and it helpfully provides a set of functions that deal with it automatically. I just didn’t use them:
if os.path.split(sPath) != '': ... month = [os.path.split(sPath) for x in range(len(days))]
os.path knows all about directory separators.