Thedircache module defines a function for reading directory listingusing a cache, and cache invalidation using themtime of the directory.Additionally, it defines a function to annotate directories by appendinga slash.
Thedircache module defines the following functions:
| ) |
| path) |
Note that the list returned should be regarded as read-only. (Perhapsa future version should change it to return a tuple?)
| path) |
| head, list) |
>>> import dircache>>> a = dircache.listdir('/')>>> a = a[:] # Copy the return value so we can change 'a'>>> a['bin', 'boot', 'cdrom', 'dev', 'etc', 'floppy', 'home', 'initrd', 'lib', 'lost+found', 'mnt', 'proc', 'root', 'sbin', 'tmp', 'usr', 'var', 'vmlinuz']>>> dircache.annotate('/', a)>>> a['bin/', 'boot/', 'cdrom/', 'dev/', 'etc/', 'floppy/', 'home/', 'initrd/', 'lib/', 'lost+found/', 'mnt/', 'proc/', 'root/', 'sbin/', 'tmp/', 'usr/', 'var/', 'vmlinuz']