Movatterモバイル変換


[0]ホーム

URL:


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:6.2 os.pathUp:6. Generic Operating SystemNext:6.4 stat

6.3dircache -- Cached directory listings

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:

listdir(path)
Return a directory listing ofpath, as gotten fromos.listdir(). Note that unlesspath changes, further calltolistdir() will not re-read the directory structure.

Note that the list returned should be regarded as read-only. (Perhapsa future version should change it to return a tuple?)

opendir(path)
Same aslistdir(). Defined for backwards compatibility.

annotate(head, list)
Assumelist is a list of paths relative tohead, and append,in place, a "/" to each path which points to a directory.

>>> 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']


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:6.2 os.pathUp:6. Generic Operating SystemNext:6.4 stat
Release 2.2.3, documentation updated on 30 May 2003.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2026 Movatter.jp