A couple of things that can clear up your code a bit:
Use the setdefault dictionary. If the key is missing, then it sets it by default, which you provide to it, and then returns it. Otherwise, it simply ignores the second parameter and returns what was in the dictionary. This avoids clumsy if-statements.
Enrol.venues_dict.setdefault(key, []).append(file) >>> x = {} >>> x.setdefault(99, []).append(5) >>> x.setdefault(99, []).append(6) >>> x {99: [5, 6]} >>> x.setdefault(100, []).append(1) >>> x {99: [5, 6], 100: [1]}
Another possibility is to use os.path.join to create file paths. This is safer than just concatenating strings.
os.path.join(dir, file)
Other than that, it looks good in terms of style, IMO.
Donald miner
source share