Update module names in references in the FAQ.

This commit is contained in:
Georg Brandl 2009-10-13 16:55:12 +00:00
parent d741315f37
commit d404fa6e1c
2 changed files with 11 additions and 15 deletions

View File

@ -232,11 +232,9 @@ Threads
How do I program using threads? How do I program using threads?
------------------------------- -------------------------------
.. XXX it's _thread in py3k Be sure to use the :mod:`threading` module and not the :mod:`_thread` module.
Be sure to use the :mod:`threading` module and not the :mod:`thread` module.
The :mod:`threading` module builds convenient abstractions on top of the The :mod:`threading` module builds convenient abstractions on top of the
low-level primitives provided by the :mod:`thread` module. low-level primitives provided by the :mod:`_thread` module.
Aahz has a set of slides from his threading tutorial that are helpful; see Aahz has a set of slides from his threading tutorial that are helpful; see
http://starship.python.net/crew/aahz/OSCON2001/. http://starship.python.net/crew/aahz/OSCON2001/.
@ -280,7 +278,7 @@ A simple fix is to add a tiny sleep to the start of the run function::
Instead of trying to guess how long a :func:`time.sleep` delay will be enough, Instead of trying to guess how long a :func:`time.sleep` delay will be enough,
it's better to use some kind of semaphore mechanism. One idea is to use the it's better to use some kind of semaphore mechanism. One idea is to use the
:mod:`Queue` module to create a queue object, let each thread append a token to :mod:`queue` module to create a queue object, let each thread append a token to
the queue when it finishes, and let the main thread read as many tokens from the the queue when it finishes, and let the main thread read as many tokens from the
queue as there are threads. queue as there are threads.
@ -288,8 +286,8 @@ queue as there are threads.
How do I parcel out work among a bunch of worker threads? How do I parcel out work among a bunch of worker threads?
--------------------------------------------------------- ---------------------------------------------------------
Use the :mod:`Queue` module to create a queue containing a list of jobs. The Use the :mod:`queue` module to create a queue containing a list of jobs. The
:class:`~Queue.Queue` class maintains a list of objects with ``.put(obj)`` to :class:`~queue.Queue` class maintains a list of objects with ``.put(obj)`` to
add an item to the queue and ``.get()`` to return an item. The class will take add an item to the queue and ``.get()`` to return an item. The class will take
care of the locking necessary to ensure that each job is handed out exactly care of the locking necessary to ensure that each job is handed out exactly
once. once.
@ -777,11 +775,10 @@ Are there any interfaces to database packages in Python?
Yes. Yes.
.. XXX remove bsddb in py3k, fix other module names Interfaces to disk-based hashes such as :mod:`DBM <dbm.ndbm>` and :mod:`GDBM
<dbm.gnu>` are also included with standard Python. There is also the
Python 2.3 includes the :mod:`bsddb` package which provides an interface to the :mod:`sqlite3` module, which provides a lightweight disk-based relational
BerkeleyDB library. Interfaces to disk-based hashes such as :mod:`DBM <dbm>` database.
and :mod:`GDBM <gdbm>` are also included with standard Python.
Support for most relational databases is available. See the Support for most relational databases is available. See the
`DatabaseProgramming wiki page `DatabaseProgramming wiki page
@ -794,8 +791,7 @@ How do you implement persistent objects in Python?
The :mod:`pickle` library module solves this in a very general way (though you The :mod:`pickle` library module solves this in a very general way (though you
still can't store things like open files, sockets or windows), and the still can't store things like open files, sockets or windows), and the
:mod:`shelve` library module uses pickle and (g)dbm to create persistent :mod:`shelve` library module uses pickle and (g)dbm to create persistent
mappings containing arbitrary Python objects. For better performance, you can mappings containing arbitrary Python objects.
use the :mod:`cPickle` module.
A more awkward way of doing things is to use pickle's little sister, marshal. A more awkward way of doing things is to use pickle's little sister, marshal.
The :mod:`marshal` module provides very fast ways to store noncircular basic The :mod:`marshal` module provides very fast ways to store noncircular basic

View File

@ -364,7 +364,7 @@ What are the "best practices" for using import in a module?
In general, don't use ``from modulename import *``. Doing so clutters the In general, don't use ``from modulename import *``. Doing so clutters the
importer's namespace. Some people avoid this idiom even with the few modules importer's namespace. Some people avoid this idiom even with the few modules
that were designed to be imported in this manner. Modules designed in this that were designed to be imported in this manner. Modules designed in this
manner include :mod:`Tkinter`, and :mod:`threading`. manner include :mod:`tkinter`, and :mod:`threading`.
Import modules at the top of a file. Doing so makes it clear what other modules Import modules at the top of a file. Doing so makes it clear what other modules
your code requires and avoids questions of whether the module name is in scope. your code requires and avoids questions of whether the module name is in scope.