mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Fix some markup and small factual glitches found by M. Markert.
This commit is contained in:
parent
07e20f8729
commit
ffefd5a8bb
2 changed files with 18 additions and 14 deletions
|
|
@ -446,14 +446,14 @@ one would hope that this somehow goes out to the filesystem, finds which
|
|||
submodules are present in the package, and imports them all. Unfortunately,
|
||||
this operation does not work very well on Windows platforms, where the
|
||||
filesystem does not always have accurate information about the case of a
|
||||
filename! On these platforms, there is no guaranteed way to know whether a file
|
||||
filename. On these platforms, there is no guaranteed way to know whether a file
|
||||
:file:`ECHO.PY` should be imported as a module :mod:`echo`, :mod:`Echo` or
|
||||
:mod:`ECHO`. (For example, Windows 95 has the annoying practice of showing all
|
||||
file names with a capitalized first letter.) The DOS 8+3 filename restriction
|
||||
adds another interesting problem for long module names.
|
||||
|
||||
The only solution is for the package author to provide an explicit index of the
|
||||
package. The import statement uses the following convention: if a package's
|
||||
package. The :keyword:`import` statement uses the following convention: if a package's
|
||||
:file:`__init__.py` code defines a list named ``__all__``, it is taken to be the
|
||||
list of module names that should be imported when ``from package import *`` is
|
||||
encountered. It is up to the package author to keep this list up-to-date when a
|
||||
|
|
@ -474,16 +474,16 @@ been imported (possibly running any initialization code in :file:`__init__.py`)
|
|||
and then imports whatever names are defined in the package. This includes any
|
||||
names defined (and submodules explicitly loaded) by :file:`__init__.py`. It
|
||||
also includes any submodules of the package that were explicitly loaded by
|
||||
previous import statements. Consider this code::
|
||||
previous :keyword:`import` statements. Consider this code::
|
||||
|
||||
import sound.effects.echo
|
||||
import sound.effects.surround
|
||||
from sound.effects import *
|
||||
|
||||
In this example, the echo and surround modules are imported in the current
|
||||
namespace because they are defined in the :mod:`sound.effects` package when the
|
||||
``from...import`` statement is executed. (This also works when ``__all__`` is
|
||||
defined.)
|
||||
In this example, the :mod:`echo` and :mod:`surround` modules are imported in the
|
||||
current namespace because they are defined in the :mod:`sound.effects` package
|
||||
when the ``from...import`` statement is executed. (This also works when
|
||||
``__all__`` is defined.)
|
||||
|
||||
Note that in general the practice of importing ``*`` from a module or package is
|
||||
frowned upon, since it often causes poorly readable code. However, it is okay to
|
||||
|
|
@ -546,5 +546,6 @@ modules found in a package.
|
|||
.. rubric:: Footnotes
|
||||
|
||||
.. [#] In fact function definitions are also 'statements' that are 'executed'; the
|
||||
execution enters the function name in the module's global symbol table.
|
||||
execution of a module-level function enters the function name in the module's
|
||||
global symbol table.
|
||||
|
||||
|
|
|
|||
|
|
@ -347,12 +347,15 @@ Decimal Floating Point Arithmetic
|
|||
|
||||
The :mod:`decimal` module offers a :class:`Decimal` datatype for decimal
|
||||
floating point arithmetic. Compared to the built-in :class:`float`
|
||||
implementation of binary floating point, the new class is especially helpful for
|
||||
financial applications and other uses which require exact decimal
|
||||
representation, control over precision, control over rounding to meet legal or
|
||||
regulatory requirements, tracking of significant decimal places, or for
|
||||
applications where the user expects the results to match calculations done by
|
||||
hand.
|
||||
implementation of binary floating point, the class is especially helpful for
|
||||
|
||||
* financial applications and other uses which require exact decimal
|
||||
representation,
|
||||
* control over precision,
|
||||
* control over rounding to meet legal or regulatory requirements,
|
||||
* tracking of significant decimal places, or
|
||||
* applications where the user expects the results to match calculations done by
|
||||
hand.
|
||||
|
||||
For example, calculating a 5% tax on a 70 cent phone charge gives different
|
||||
results in decimal floating point and binary floating point. The difference
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue