[Doc-SIG] tut.tex errors and typos

Denis S. Otkidach den@analyt.chem.msu.ru
Tue, 18 Apr 2000 13:25:05 +0300


Hi!

While translating tutorial into Russian I have encountered some errors and
typos. Here they are. (Sorry for bad English -- it's not my native
language.)

tut.tex, l:2078
> \emph{first} time the module is imported somewhere.\footnote{
>         In fact function definitions are also `statements' that are
>         `executed'; the execution enters the function name in the
>         module's global symbol table.
                   ^^^^^^ local

tut.tex, l:2096
> script, for that matter).  The imported module names are placed in the
> importing module's global symbol table.
                     ^^^^^^ local

Here is an example demonstrating that names are introduced in local symbol
table:

>>> def f():
...     import string
...
>>> string
Traceback (innermost last):
  File "<stdin>", line 1, in ?
NameError: string
>>> f()
>>> string
Traceback (innermost last):
  File "<stdin>", line 1, in ?
NameError: string
>>>

============================================================================
===

tut.tex, l:3509
> Data attributes may be referenced by methods as well as by ordinary
> users (``clients'') of an object.  In other words, classes are not
> usable to implement pure abstract data types.  In fact, nothing in
> Python makes it possible to enforce data hiding --- it is all based
> upon convention.  (On the other hand, the Python implementation,
> written in C, can completely hide implementation details and control
> access to an object if necessary; this can be used by extensions to
> Python written in C.)
>
>
> Clients should use data attributes with care --- clients may mess up
> invariants maintained by the methods by stamping on their data
> attributes.  Note that clients may add data attributes of their own to
> an instance object without affecting the validity of the methods, as
> long as name conflicts are avoided --- again, a naming convention can
> save a lot of headaches here.

I propose something like the folowing:

Some classes require data attributes to be hidden to avoid accidential
corruption of object invariant. You can hide attributes using names
prefixed with at least two uderscores and with at most one underscore
--- such attributes are private and are
accessible from instance methods only. (In fact you can access private
data attributes using special name convention, but this won't be
accidential. See also section \ref{private}.)

============================================================================
===

tut.tex, l:3582
> Methods may reference global names in the same way as ordinary
> functions.  The global scope associated with a method is the module
> containing the class definition.  (The class itself is never used as a
                 ^^^^^ function (usually the same as containing class
                       definition)

Here is an example:

module.py:
----------
gv = "module"
def f(self):
    global gv
    print gv

prog.py:
--------
import module
gv="prog"
class c:
    m=module.f
o=c()
o.m()

result of prog.py execution:
----------------------------
module

============================================================================
===

tut.tex, l:2797
> Strings can easily be written to and read from a file. Numbers take a
> bit more effort, since the \method{read()} method only returns
> strings, which will have to be passed to a function like
> \function{string.atoi()}, which takes a string like \code{'123'} and
            ^^^^^^^^^^^^^ int()
> returns its numeric value 123.  However, when you want to save more

string.atoi() is deprecated.

============================================================================
===

Just a typo...

tut.tex, l:750
> characters. This lead to very much confusion especially with respect
> to internalization (usually written as \samp{i18n} --- \character{i} +
     ^^^^^^^^^^^^^^^ internationalization
> 18 characters + \character{n}) of software. Unicode solves these

============================================================================
===

tut.tex, l:768
> \begin{verbatim}
> >>> u'Hello\\u0020World !'
             ^^^ \u (at least Russian-enabled LaTeX eat it)
> u'Hello World !'
> \end{verbatim}
>
> The escape sequence \code{\\u0020} indicates to insert the Unicode
                            ^^^ \e u

\\ causes linebreak

============================================================================
===

tut.tex, l:799
> Apart from these standard encodings, Python provides a whole set of
> other ways of creating Unicod strings on the basis of a known
                         ^^^^^^ Unicode
> encoding.

With best regards,
Denis.