Movatterモバイル変換


[0]ホーム

URL:


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:7.10 dbhashUp:7.10 dbhashNext:7.11 whichdb

 
7.10.1 Database Objects

The database objects returned byopen() provide the methods common to all the DBM-style databases. The following methods areavailable in addition to the standard methods.

first()
It's possible to loop over every key in the database using this method and thenext() method. The traversal is ordered by the databases internal hash values, and won't be sorted by the key values. This method returns the starting key.

last()
Return the last key in a database traversal. This may be used to begin a reverse-order traversal; seeprevious().

next(key)
Returns the key that followskey in the traversal. The following code prints every key in the databasedb, without having to create a list in memory that contains them all:

k = db.first()while k != None:    print k    k = db.next(k)

previous(key)
Return the key that comes beforekey in a forward-traversal of the database. In conjunction withlast(), this may be used to implement a reverse-order traversal.

sync()
This method forces any unwritten data to be written to the disk.


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:7.10 dbhashUp:7.10 dbhashNext:7.11 whichdb
Release 2.2.3, documentation updated on 30 May 2003.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2026 Movatter.jp