Kaydet (Commit) ffefd5a8 authored tarafından Georg Brandl's avatar Georg Brandl

Fix some markup and small factual glitches found by M. Markert.

üst 07e20f87
...@@ -446,14 +446,14 @@ one would hope that this somehow goes out to the filesystem, finds which ...@@ -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, submodules are present in the package, and imports them all. Unfortunately,
this operation does not work very well on Windows platforms, where the this operation does not work very well on Windows platforms, where the
filesystem does not always have accurate information about the case of a 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 :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 :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 file names with a capitalized first letter.) The DOS 8+3 filename restriction
adds another interesting problem for long module names. adds another interesting problem for long module names.
The only solution is for the package author to provide an explicit index of the 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 :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 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 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`) ...@@ -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 and then imports whatever names are defined in the package. This includes any
names defined (and submodules explicitly loaded) by :file:`__init__.py`. It names defined (and submodules explicitly loaded) by :file:`__init__.py`. It
also includes any submodules of the package that were explicitly loaded by 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.echo
import sound.effects.surround import sound.effects.surround
from sound.effects import * from sound.effects import *
In this example, the echo and surround modules are imported in the current In this example, the :mod:`echo` and :mod:`surround` modules are imported in the
namespace because they are defined in the :mod:`sound.effects` package when the current namespace because they are defined in the :mod:`sound.effects` package
``from...import`` statement is executed. (This also works when ``__all__`` is when the ``from...import`` statement is executed. (This also works when
defined.) ``__all__`` is defined.)
Note that in general the practice of importing ``*`` from a module or package is 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 frowned upon, since it often causes poorly readable code. However, it is okay to
...@@ -546,5 +546,6 @@ modules found in a package. ...@@ -546,5 +546,6 @@ modules found in a package.
.. rubric:: Footnotes .. rubric:: Footnotes
.. [#] In fact function definitions are also 'statements' that are 'executed'; the .. [#] 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 ...@@ -347,12 +347,15 @@ Decimal Floating Point Arithmetic
The :mod:`decimal` module offers a :class:`Decimal` datatype for decimal The :mod:`decimal` module offers a :class:`Decimal` datatype for decimal
floating point arithmetic. Compared to the built-in :class:`float` floating point arithmetic. Compared to the built-in :class:`float`
implementation of binary floating point, the new class is especially helpful for 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 * financial applications and other uses which require exact decimal
regulatory requirements, tracking of significant decimal places, or for representation,
applications where the user expects the results to match calculations done by * control over precision,
hand. * 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 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 results in decimal floating point and binary floating point. The difference
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment