diff options
author | Fred Drake <fdrake@acm.org> | 2003-09-11 04:28:13 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2003-09-11 04:28:13 (GMT) |
commit | 626d472eddb29711cf28da1986e9e12b780b7662 (patch) | |
tree | 4b7f619b005bc07b0890f95d22755d7fa05198b7 /Doc | |
parent | 11b138fbf76c33ef184f006b6069f512fdd648cc (diff) | |
download | cpython-626d472eddb29711cf28da1986e9e12b780b7662.zip cpython-626d472eddb29711cf28da1986e9e12b780b7662.tar.gz cpython-626d472eddb29711cf28da1986e9e12b780b7662.tar.bz2 |
- add several links into the library reference
- update a couple of URLs to point to more recent portions of
python.org
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/tut/tut.tex | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index a730860..50ba5e9 100644 --- a/Doc/tut/tut.tex +++ b/Doc/tut/tut.tex @@ -329,19 +329,19 @@ With that declaration, all characters in the source file will be treated as possible to directly write Unicode string literals in the selected encoding. The list of possible encodings can be found in the \citetitle[../lib/lib.html]{Python Library Reference}, in the section -on \module{codecs}. +on \ulink{\module{codecs}}{../lib/module-codecs.html}. -If your editor supports saving files as \code{UTF-8} with an UTF-8 -signature (aka BOM -- Byte Order Mark), you can use that instead of an +If your editor supports saving files as \code{UTF-8} with a UTF-8 +\emph{byte order mark} (aka BOM), you can use that instead of an encoding declaration. IDLE supports this capability if \code{Options/General/Default Source Encoding/UTF-8} is set. Notice that this signature is not understood in older Python releases (2.2 and earlier), and also not understood by the operating system for -\code{\#!} files. +\code{\#!} files. By using UTF-8 (either through the signature or an encoding declaration), characters of most languages in the world can be used -simultaneously in string literals and comments. Using non-ASCII +simultaneously in string literals and comments. Using non-\ASCII characters in identifiers is not supported. To display all these characters properly, your editor must recognize that the file is UTF-8, and it must use a font that supports all the characters in the @@ -879,7 +879,7 @@ the more well known encodings which these codecs can convert are \emph{Latin-1}, \emph{ASCII}, \emph{UTF-8}, and \emph{UTF-16}. The latter two are variable-length encodings that store each Unicode character in one or more bytes. The default encoding is -normally set to ASCII, which passes through characters in the range +normally set to \ASCII, which passes through characters in the range 0 to 127 and rejects any other characters with an error. When a Unicode string is printed, written to a file, or converted with \function{str()}, conversion takes place using this default encoding. @@ -2393,7 +2393,7 @@ script being run is on the search path, it is important that the script not have the same name as a standard module, or Python will attempt to load the script as a module when that module is imported. This will generally be an error. See section~\ref{standardModules}, -``Standard Modules.'' for more information. +``Standard Modules,'' for more information. \subsection{``Compiled'' Python files} @@ -2459,9 +2459,10 @@ library of Python code in a form that is moderately hard to reverse engineer. \item -The module \module{compileall}\refstmodindex{compileall} can create -\file{.pyc} files (or \file{.pyo} files when \programopt{-O} is used) for -all modules in a directory. +The module \ulink{\module{compileall}}{../lib/module-compileall.html}% +{} \refstmodindex{compileall} can create \file{.pyc} files (or +\file{.pyo} files when \programopt{-O} is used) for all modules in a +directory. \end{itemize} @@ -2478,7 +2479,8 @@ system calls. The set of such modules is a configuration option which also dependson the underlying platform For example, the \module{amoeba} module is only provided on systems that somehow support Amoeba primitives. One particular module deserves some -attention: \module{sys}\refstmodindex{sys}, which is built into every +attention: \ulink{\module{sys}}{../lib/module-sys.html}% +\refstmodindex{sys}, which is built into every Python interpreter. The variables \code{sys.ps1} and \code{sys.ps2} define the strings used as primary and secondary prompts: @@ -2761,14 +2763,15 @@ submodules with the same name from different packages. \subsection{Intra-package References} The submodules often need to refer to each other. For example, the -\module{surround} module might use the \module{echo} module. In fact, such references -are so common that the \code{import} statement first looks in the +\module{surround} module might use the \module{echo} module. In fact, +such references +are so common that the \keyword{import} statement first looks in the containing package before looking in the standard module search path. Thus, the surround module can simply use \code{import echo} or \code{from echo import echofilter}. If the imported module is not found in the current package (the package of which the current module -is a submodule), the \code{import} statement looks for a top-level module -with the given name. +is a submodule), the \keyword{import} statement looks for a top-level +module with the given name. When packages are structured into subpackages (as with the \module{Sound} package in the example), there's no shortcut to refer @@ -2778,15 +2781,6 @@ must be used. For example, if the module in the \module{Sound.Effects} package, it can use \code{from Sound.Effects import echo}. -%(One could design a notation to refer to parent packages, similar to -%the use of ".." to refer to the parent directory in \UNIX{} and Windows -%filesystems. In fact, the \module{ni} module, which was the -%ancestor of this package system, supported this using \code{__} for -%the package containing the current module, -%\code{__.__} for the parent package, and so on. This feature was dropped -%because of its awkwardness; since most packages will have a relative -%shallow substructure, this is no big loss.) - \subsection{Packages in Multiple Directories} Packages support one more special attribute, \member{__path__}. This @@ -3123,7 +3117,8 @@ things get a lot more complicated. Rather than have users be constantly writing and debugging code to save complicated data types, Python provides a standard module called -\module{pickle}. This is an amazing module that can take almost +\ulink{\module{pickle}}{../lib/module-pickle.html}. This is an +amazing module that can take almost any Python object (even some forms of Python code!), and convert it to a string representation; this process is called \dfn{pickling}. Reconstructing the object from the string representation is called @@ -3148,12 +3143,15 @@ x = pickle.load(f) (There are other variants of this, used when pickling many objects or when you don't want to write the pickled data to a file; consult the -complete documentation for \module{pickle} in the Library Reference.) - -\module{pickle} is the standard way to make Python objects which can -be stored and reused by other programs or by a future invocation of -the same program; the technical term for this is a -\dfn{persistent} object. Because \module{pickle} is so widely used, +complete documentation for +\ulink{\module{pickle}}{../lib/module-pickle.html} in the +\citetitle[../lib/]{Python Library Reference}.) + +\ulink{\module{pickle}}{../lib/module-pickle.html} is the standard way +to make Python objects which can be stored and reused by other +programs or by a future invocation of the same program; the technical +term for this is a \dfn{persistent} object. Because +\ulink{\module{pickle}}{../lib/module-pickle.html} is so widely used, many authors who write Python extensions take care to ensure that new data types such as matrices can be properly pickled and unpickled. @@ -4356,8 +4354,8 @@ than the main site, depending on your geographical location. A more informal site is \url{http://starship.python.net/}, which contains a bunch of Python-related personal home pages; many people have downloadable software there. Many more user-created Python modules -can be found in a third-party repository at -\url{http://www.vex.net/parnassus}. +can be found in the \ulink{Python Package +Index}{http://www.python.org/pypi} (PyPI). For Python-related questions and problem reports, you can post to the newsgroup \newsgroup{comp.lang.python}, or send them to the mailing @@ -4370,8 +4368,7 @@ up to several hundred), % days = 116.9 msgs / day and steadily increasing. asking (and answering) questions, suggesting new features, and announcing new modules. Before posting, be sure to check the list of -Frequently Asked Questions (also called the FAQ), at -\url{http://www.python.org/doc/FAQ.html}, or look for it in the +\ulink{Frequently Asked Questions}{http://www.python.org/doc/faq/} (also called the FAQ), or look for it in the \file{Misc/} directory of the Python source distribution. Mailing list archives are available at \url{http://www.python.org/pipermail/}. The FAQ answers many of the questions that come up again and again, @@ -4498,7 +4495,8 @@ this deletes the names it creates once they are no longer needed; this is done since the startup file is executed in the same namespace as the interactive commands, and removing the names avoids creating side effects in the interactive environments. You may find it convenient -to keep some of the imported modules, such as \module{os}, which turn +to keep some of the imported modules, such as +\ulink{\module{os}}{../lib/module-os.html}, which turn out to be needed in most sessions with the interpreter. \begin{verbatim} |