}
# Output file base name for HTML help builder.
-htmlhelp_basename = 'pydoc'
+htmlhelp_basename = 'python' + release.replace('.', '')
# Options for LaTeX output
Python and this documentation is:
-Copyright © 2001-2007 Python Software Foundation. All rights reserved.
+Copyright © 2001-2008 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Each result tuple is ordered to match the input order. So, every
combination is a subsequence of the input *iterable*.
- Example: ``combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)``
-
Equivalent to::
def combinations(iterable, r):
+ 'combinations(range(4), 3) --> (0,1,2) (0,1,3) (0,2,3) (1,2,3)'
pool = tuple(iterable)
n = len(pool)
- assert 0 <= r <= n
- vec = range(r)
- yield tuple(pool[i] for i in vec)
+ indices = range(r)
+ yield tuple(pool[i] for i in indices)
while 1:
for i in reversed(range(r)):
- if vec[i] != i + n - r:
+ if indices[i] != i + n - r:
break
else:
return
- vec[i] += 1
+ indices[i] += 1
for j in range(i+1, r):
- vec[j] = vec[j-1] + 1
- yield tuple(pool[i] for i in vec)
+ indices[j] = indices[j-1] + 1
+ yield tuple(pool[i] for i in indices)
.. versionadded:: 2.6
value. So if the input elements are unique, there will be no repeat
values in each permutation.
- Example: ``permutations(range(3),2) --> (1,2) (1,3) (2,1) (2,3) (3,1) (3,2)``
+ Equivalent to::
+
+ def permutations(iterable, r=None):
+ 'permutations(range(3), 2) --> (0,1) (0,2) (1,0) (1,2) (2,0) (2,1)'
+ pool = tuple(iterable)
+ n = len(pool)
+ r = n if r is None else r
+ indices = range(n)
+ cycles = range(n-r+1, n+1)[::-1]
+ yield tuple(pool[i] for i in indices[:r])
+ while n:
+ for i in reversed(range(r)):
+ cycles[i] -= 1
+ if cycles[i] == 0:
+ indices[i:] = indices[i+1:] + indices[i:i+1]
+ cycles[i] = n - i
+ else:
+ j = cycles[i]
+ indices[i], indices[-j] = indices[-j], indices[i]
+ yield tuple(pool[i] for i in indices[:r])
+ break
+ else:
+ return
.. versionadded:: 2.6
You can use the *when* to specify the type of *interval*. The list of possible
values is, note that they are not case sensitive:
- +----------+-----------------------+
- | Value | Type of interval |
- +==========+=======================+
- | S | Seconds |
- +----------+-----------------------+
- | M | Minutes |
- +----------+-----------------------+
- | H | Hours |
- +----------+-----------------------+
- | D | Days |
- +----------+-----------------------+
- | W | Week day (0=Monday) |
- +----------+-----------------------+
- | midnight | Roll over at midnight |
- +----------+-----------------------+
-
- If *backupCount* is non-zero, the system will save old log files by appending
- extensions to the filename. The extensions are date-and-time based, using the
- strftime format ``%Y-%m-%d_%H-%M-%S`` or a leading portion thereof, depending on
- the rollover interval. At most *backupCount* files will be kept, and if more
- would be created when rollover occurs, the oldest one is deleted.
+ +----------------+-----------------------+
+ | Value | Type of interval |
+ +================+=======================+
+ | ``'S'`` | Seconds |
+ +----------------+-----------------------+
+ | ``'M'`` | Minutes |
+ +----------------+-----------------------+
+ | ``'H'`` | Hours |
+ +----------------+-----------------------+
+ | ``'D'`` | Days |
+ +----------------+-----------------------+
+ | ``'W'`` | Week day (0=Monday) |
+ +----------------+-----------------------+
+ | ``'midnight'`` | Roll over at midnight |
+ +----------------+-----------------------+
+
+ The system will save old log files by appending extensions to the filename.
+ The extensions are date-and-time based, using the strftime format
+ ``%Y-%m-%d_%H-%M-%S`` or a leading portion thereof, depending on the rollover
+ interval. If *backupCount* is nonzero, at most *backupCount* files will be
+ kept, and if more would be created when rollover occurs, the oldest one is
+ deleted.
.. method:: TimedRotatingFileHandler.doRollover()
analyze, test, perform and/or display publicly, prepare derivative works,
distribute, and otherwise use Python |release| alone or in any derivative
version, provided, however, that PSF's License Agreement and PSF's notice of
- copyright, i.e., "Copyright © 2001-2007 Python Software Foundation; All Rights
+ copyright, i.e., "Copyright © 2001-2008 Python Software Foundation; All Rights
Reserved" are retained in Python |release| alone or in any derivative version
prepared by Licensee.
print >>sys.stderr, 'Can\'t get version info from Include/patchlevel.h, ' \
'using version of this interpreter (%s).' % release
return version, release
+
+if __name__ == '__main__':
+ print get_header_version_info('.')[1]
# For Python 2.3
from bsddb import db, dbshelve
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
#----------------------------------------------------------------------
def tearDown(self):
self.env.close()
self.env = None
- from test import test_support
test_support.rmtree(self.homeDir)
def test00_associateDBError(self):
import string
import tempfile
from pprint import pprint
-from test import test_support
import unittest
import time
from bsddb import db
from bsddb.test.test_all import verbose
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
DASH = b'-'
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
# For Python 2.3
from bsddb import db, dbshelve
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
lexical_cmp = cmp
def lowercase_cmp(left, right):
if self.env is not None:
self.env.close ()
self.env = None
- from test import test_support
test_support.rmtree(self.homeDir)
def addDataToDB (self, data):
from bsddb import db
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
#----------------------------------------------------------------------
del self.secondary_db
del self.primary_db
del self.env
- from test import test_support
test_support.rmtree(self.homeDir)
def test_pget(self):
# For Python 2.3
from bsddb import db, dbobj
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
#----------------------------------------------------------------------
del self.db
if hasattr(self, 'env'):
del self.env
- from test import test_support
test_support.rmtree(self.homeDir)
def test01_both(self):
from bsddb import db, dbshelve
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
from bsddb.test.test_all import verbose
def tearDown(self):
- from test import test_support
test_support.rmtree(self.homeDir)
self.do_close()
# For Python 2.3
from bsddb import db, dbtables
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
#----------------------------------------------------------------------
def tearDown(self):
self.tdb.close()
- from test import test_support
test_support.rmtree(self.testHomeDir)
def test01(self):
# For Python 2.3
from bsddb import db
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
from bsddb.test.test_all import verbose
# We're going to get warnings in this module about trying to close the db when
tempfile.tempdir = None
def tearDown(self):
- from test import test_support
test_support.rmtree(self.homeDir)
def test01_close_dbenv_before_db(self):
from bsddb import db, dbshelve, StringKeys
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
#----------------------------------------------------------------------
def tearDown(self):
self.env.close()
- from test import test_support
test_support.rmtree(self.homeDir)
def test01_join(self):
# For Python 2.3
from bsddb import db
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
#----------------------------------------------------------------------
def tearDown(self):
self.env.close()
- from test import test_support
test_support.rmtree(self.homeDir)
# For the bundled bsddb
from bsddb import db, dbshelve, hashopen
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
#----------------------------------------------------------------------
class MiscTestCase(unittest.TestCase):
pass
def tearDown(self):
- from test import test_support
test_support.unlink(self.filename)
test_support.rmtree(self.homeDir)
# For Python 2.3
from bsddb import db
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
#----------------------------------------------------------------------
del self.db
if hasattr(self, 'env'):
del self.env
- from test import test_support
test_support.rmtree(self.homeDir)
def _base_test_pickle_DBError(self, pickle):
# For Python 2.3
from bsddb import db
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
self.homeDir = None
def tearDown(self):
- from test import test_support
test_support.unlink(self.filename)
if self.homeDir:
test_support.rmtree(self.homeDir)
from bsddb import db
from bsddb.test.test_all import verbose
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
class DBSequenceTest(unittest.TestCase):
self.dbenv.close()
del self.dbenv
- from test import test_support
test_support.rmtree(self.homeDir)
def test_get(self):
# For Python 2.3
from bsddb import db, dbutils
+try:
+ from bsddb3 import test_support
+except ImportError:
+ from test import test_support
+
#----------------------------------------------------------------------
self.d.open(self.filename, self.dbtype, self.dbopenflags|db.DB_CREATE)
def tearDown(self):
- from test import test_support
test_support.rmtree(self.homeDir)
self.d.close()
self.env.close()
typedef struct {
PyObject_HEAD
PyObject *pools; /* tuple of pool tuples */
- Py_ssize_t *maxvec; /* size of each pool */
Py_ssize_t *indices; /* one index per pool */
PyObject *result; /* most recently returned result tuple */
int stopped; /* set to 1 when the product iterator is exhausted */
productobject *lz;
Py_ssize_t nargs, npools, repeat=1;
PyObject *pools = NULL;
- Py_ssize_t *maxvec = NULL;
Py_ssize_t *indices = NULL;
Py_ssize_t i;
nargs = (repeat == 0) ? 0 : PyTuple_GET_SIZE(args);
npools = nargs * repeat;
- maxvec = PyMem_Malloc(npools * sizeof(Py_ssize_t));
indices = PyMem_Malloc(npools * sizeof(Py_ssize_t));
- if (maxvec == NULL || indices == NULL) {
+ if (indices == NULL) {
PyErr_NoMemory();
goto error;
}
PyObject *pool = PySequence_Tuple(item);
if (pool == NULL)
goto error;
-
PyTuple_SET_ITEM(pools, i, pool);
- maxvec[i] = PyTuple_GET_SIZE(pool);
indices[i] = 0;
}
for ( ; i < npools; ++i) {
PyObject *pool = PyTuple_GET_ITEM(pools, i - nargs);
Py_INCREF(pool);
PyTuple_SET_ITEM(pools, i, pool);
- maxvec[i] = maxvec[i - nargs];
indices[i] = 0;
}
goto error;
lz->pools = pools;
- lz->maxvec = maxvec;
lz->indices = indices;
lz->result = NULL;
lz->stopped = 0;
return (PyObject *)lz;
error:
- if (maxvec != NULL)
- PyMem_Free(maxvec);
if (indices != NULL)
PyMem_Free(indices);
Py_XDECREF(pools);
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->pools);
Py_XDECREF(lz->result);
- PyMem_Free(lz->maxvec);
PyMem_Free(lz->indices);
Py_TYPE(lz)->tp_free(lz);
}
}
} else {
Py_ssize_t *indices = lz->indices;
- Py_ssize_t *maxvec = lz->maxvec;
/* Copy the previous result tuple or re-use it if available */
if (Py_REFCNT(result) > 1) {
Py_DECREF(old_result);
}
/* Now, we've got the only copy so we can update it in-place */
- assert (Py_REFCNT(result) == 1);
+ assert (npools==0 || Py_REFCNT(result) == 1);
/* Update the pool indices right-to-left. Only advance to the
next pool when the previous one rolls-over */
for (i=npools-1 ; i >= 0 ; i--) {
pool = PyTuple_GET_ITEM(pools, i);
indices[i]++;
- if (indices[i] == maxvec[i]) {
+ if (indices[i] == PyTuple_GET_SIZE(pool)) {
/* Roll-over and advance to next pool */
indices[i] = 0;
elem = PyTuple_GET_ITEM(pool, 0);
==================================
For notes specific to this release, see RELNOTES in this directory.
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+Python Software Foundation.
+All rights reserved.
Python 3000 (a.k.a. "Py3k", and released as Python 3.0) is a new
version of the language, which is incompatible with the 2.x line of