Vous devez avoir un compte Developpez.com et être connecté pour pouvoir participer aux discussions.

Mot de passe
Mot de passe oublié ?
Créer un compte

Vous n'avez pas encore de compte Developpez.com ? L'inscription est gratuite et ne vous prendra que quelques instants !

Je m'inscris !



Choisissez la catégorie, puis la rubrique :

13.10.1 Database Objects

13.10.1 Database Objects

The database objects returned by open() provide the methods common to all the DBM-style databases and mapping objects. The following methods are available in addition to the standard methods.

first( )
It's possible to loop over every key/value pair in the database using this method and the next() 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/value pair in a database traversal. This may be used to begin a reverse-order traversal; see previous().

next( )
Returns the key next key/value pair in a database traversal. The following code prints every key in the database db, without having to create a list in memory that contains them all:

print db.first()
for i in xrange(1, len(db)):
    print db.next()

previous( )
Returns the previous key/value pair in a forward-traversal of the database. In conjunction with last(), this may be used to implement a reverse-order traversal.

sync( )
This method forces any unwritten data to be written to the disk.
See About this document... for information on suggesting changes.
Contacter le responsable de la rubrique Python

Partenaire : Hébergement Web