mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	 805365ee39
			
		
	
	
		805365ee39
		
	
	
	
	
		
			
			svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55077 | guido.van.rossum | 2007-05-02 11:54:37 -0700 (Wed, 02 May 2007) | 2 lines Use the new print syntax, at least. ........ r55142 | fred.drake | 2007-05-04 21:27:30 -0700 (Fri, 04 May 2007) | 1 line remove old cruftiness ........ r55143 | fred.drake | 2007-05-04 21:52:16 -0700 (Fri, 04 May 2007) | 1 line make this work with the new Python ........ r55162 | neal.norwitz | 2007-05-06 22:29:18 -0700 (Sun, 06 May 2007) | 1 line Get asdl code gen working with Python 2.3. Should continue to work with 3.0 ........ r55164 | neal.norwitz | 2007-05-07 00:00:38 -0700 (Mon, 07 May 2007) | 1 line Verify checkins to p3yk (sic) branch go to 3000 list. ........ r55166 | neal.norwitz | 2007-05-07 00:12:35 -0700 (Mon, 07 May 2007) | 1 line Fix this test so it runs again by importing warnings_test properly. ........ r55167 | neal.norwitz | 2007-05-07 01:03:22 -0700 (Mon, 07 May 2007) | 8 lines So long xrange. range() now supports values that are outside -sys.maxint to sys.maxint. floats raise a TypeError. This has been sitting for a long time. It probably has some problems and needs cleanup. Objects/rangeobject.c now uses 4-space indents since it is almost completely new. ........ r55171 | guido.van.rossum | 2007-05-07 10:21:26 -0700 (Mon, 07 May 2007) | 4 lines Fix two tests that were previously depending on significant spaces at the end of a line (and before that on Python 2.x print behavior that has no exact equivalent in 3.0). ........
		
			
				
	
	
		
			88 lines
		
	
	
	
		
			3.2 KiB
		
	
	
	
		
			TeX
		
	
	
	
	
	
			
		
		
	
	
			88 lines
		
	
	
	
		
			3.2 KiB
		
	
	
	
		
			TeX
		
	
	
	
	
	
| \section{\module{dbhash} ---
 | |
|          DBM-style interface to the BSD database library}
 | |
| 
 | |
| \declaremodule{standard}{dbhash}
 | |
| \modulesynopsis{DBM-style interface to the BSD database library.}
 | |
| \sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
 | |
| 
 | |
| 
 | |
| The \module{dbhash} module provides a function to open databases using
 | |
| the BSD \code{db} library.  This module mirrors the interface of the
 | |
| other Python database modules that provide access to DBM-style
 | |
| databases.  The \refmodule{bsddb}\refbimodindex{bsddb} module is required 
 | |
| to use \module{dbhash}.
 | |
| 
 | |
| This module provides an exception and a function:
 | |
| 
 | |
| 
 | |
| \begin{excdesc}{error}
 | |
|   Exception raised on database errors other than
 | |
|   \exception{KeyError}.  It is a synonym for \exception{bsddb.error}.
 | |
| \end{excdesc}
 | |
| 
 | |
| \begin{funcdesc}{open}{path\optional{, flag\optional{, mode}}}
 | |
|   Open a \code{db} database and return the database object.  The
 | |
|   \var{path} argument is the name of the database file.
 | |
| 
 | |
|   The \var{flag} argument can be
 | |
|   \code{'r'} (the default), \code{'w'},
 | |
|   \code{'c'} (which creates the database if it doesn't exist), or
 | |
|   \code{'n'} (which always creates a new empty database).
 | |
|   For platforms on which the BSD \code{db} library supports locking,
 | |
|   an \character{l} can be appended to indicate that locking should be
 | |
|   used.
 | |
| 
 | |
|   The optional \var{mode} parameter is used to indicate the \UNIX{}
 | |
|   permission bits that should be set if a new database must be
 | |
|   created; this will be masked by the current umask value for the
 | |
|   process.
 | |
| \end{funcdesc}
 | |
| 
 | |
| 
 | |
| \begin{seealso}
 | |
|   \seemodule{anydbm}{Generic interface to \code{dbm}-style databases.}
 | |
|   \seemodule{bsddb}{Lower-level interface to the BSD \code{db} library.}
 | |
|   \seemodule{whichdb}{Utility module used to determine the type of an
 | |
|                       existing database.}
 | |
| \end{seealso}
 | |
| 
 | |
| 
 | |
| \subsection{Database Objects \label{dbhash-objects}}
 | |
| 
 | |
| The database objects returned by \function{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.
 | |
| 
 | |
| \begin{methoddesc}[dbhash]{first}{}
 | |
|   It's possible to loop over every key/value pair in the database using
 | |
|   this method   and the \method{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.
 | |
| \end{methoddesc}
 | |
| 
 | |
| \begin{methoddesc}[dbhash]{last}{}
 | |
|   Return the last key/value pair in a database traversal.  This may be used to
 | |
|   begin a reverse-order traversal; see \method{previous()}.
 | |
| \end{methoddesc}
 | |
| 
 | |
| \begin{methoddesc}[dbhash]{next}{}
 | |
|   Returns the key next key/value pair in a database traversal.  The
 | |
|   following code prints every key in the database \code{db}, without
 | |
|   having to create a list in memory that contains them all:
 | |
| 
 | |
| \begin{verbatim}
 | |
| print db.first()
 | |
| for i in range(1, len(db)):
 | |
|     print db.next()
 | |
| \end{verbatim}
 | |
| \end{methoddesc}
 | |
| 
 | |
| \begin{methoddesc}[dbhash]{previous}{}
 | |
|   Returns the previous key/value pair in a forward-traversal of the database.
 | |
|   In conjunction with \method{last()}, this may be used to implement
 | |
|   a reverse-order traversal.
 | |
| \end{methoddesc}
 | |
| 
 | |
| \begin{methoddesc}[dbhash]{sync}{}
 | |
|   This method forces any unwritten data to be written to the disk.
 | |
| \end{methoddesc}
 |