Before I go reinventing the wheel, can anyone tell me if there's a drop-in (or semi-drop-in) replacement for the single-line statement:
allfiles = dircache.listdir('.')
One line? No. But you can just do:
global_cache = {}
def cached_listdir(path):
res = global_cache.get(path)
if res is None:
res = os.listdir(path)
global_cache[path] = res
return res
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments