Python 0.9.4alpha under the Christmas tree!

Guido van Rossum (Guido.van.Rossum@cwi.nl)
Tue, 24 Dec 91 13:20:17 +0100

After all I think it's better to release 0.9.4 now to see what people
think of it anyway, rather than waiting forever until I find the time
to perfect the documentation (it certainly isn't going to happen over
Christmas).

I've uploaded it to the following three places:

host directory

uunet.uu.net /tmp
wuarchive.wustl.edu /pub
ftp.cwi.nl /pub

You should fetch the file python0.9.4alpha.tar.Z. If you haven't got
STDWIN yet, you can fetch that too, from the same locations; the file
is stdwin0.9.6.tar.Z. I don't know what's an appropriate place to get
bash/readline from, sorry.

I don't know how long the uunet and wuarchive versions will stay
around; I have some control over ftp.cwi.nl so I think those versions
will stay put, but people in North America should first try either US
site to avoid excessive transatlantic traffic (and Europeans should
try ftp.cwi.nl first!).

Don't ask me to mail it to you; find a friend with Internet ftp access
instead.

Below are the PREFACE and NEWS files from the distribution (directory
misc):

---------------------------------- NEWS --------------------------------
This is the announcement of Python 0.9.4 alpha. I call it an alpha
release because it is not widely distributed, only to readers of the
Python mailing list, and because the documentation does not yet
describe the new features yet. However, installation should be
smooth, and I don't expect there are obvious bugs left.

In particular, these changes are not yet documented:

- New class syntax, without extraneous parentheses.
- New 'global' statement to assign global variables from within a function.
- New, more refined exceptions.
- New argument passing semantics.

The release can be picked up by anonymous ftp from site ftp.cwi.nl,
directory pub, file python0.9.4beta.tar.Z. I will also upload
versions to wuarchive.wustl.edu:/pub and to uunet.uu.net:/tmp. Please
don't ask me to mail it to you; find a friend with Internet ftp access
instead.

The rest of this file contains explanation for the changes listed above.

--Guido van Rossum, CWI, Amsterdam <guido@cwi.nl>
"Oh Bevis! And I thought you were so rugged!"

New class syntax
----------------

You can now declare a base class as follows:

class B: # Was: class B():
def some_method(self): ...
...

and a derived class thusly:

class D(B): # Was: class D() = B():
def another_method(self, arg): ...

Multiple inheritance looks like this:

class M(B, D): # Was: class M() = B(), D():
def this_or_that_method(self, arg): ...

The old syntax is still accepted by Python 0.9.4, but will disappear
in Python 1.0 (to be posted to comp.sources).

New 'global' statement
----------------------

Every now and then you have a global variable in a module that you
want to change from within a function in that module -- say, a count
of calls to a function, or an option flag, etc. Until now this was
not directly possible. While several kludges are known that
circumvent the problem, and often the need for a global variable can
be avoided by rewriting the module as a class, this does not always
lead to clearer code.

The 'global' statement solves this dilemma. Its occurrence in a
function body means that, for the duration of that function, the
names listed there refer to global variables. For instance:

total = 0.0
count = 0

def add_to_total(amount):
global total, count
total = total + amount
count = count + 1

'global' must be repeated in each function where it is needed. The
names listed in a 'global' statement must not be used in the function
before the statement is reached.

Remember that you don't need to use 'global' if you only want to *use*
a global variable in a function; nor do you need ot for assignments to
parts of global variables (e.g., list or dictionary items or
attributes of class instances). This has not changed; in fact
assignment to part of a global variable was the standard workaround.

New exceptions
--------------

Several new exceptions have been defined, to distinguish more clearly
between different types of errors.

name meaning was

AttributeError reference to non-existing attribute NameError
IOError unexpected I/O error RuntimeError
ImportError import of non-existing module or name NameError
IndexError invalid string, tuple or list index RuntimeError
KeyError key not in dictionary RuntimeError
OverflowError numeric overflow RuntimeError
SyntaxError invalid syntax RuntimeError
ValueError invalid argument value RuntimeError
ZeroDivisionError division by zero RuntimeError

The string value of each exception is now its name -- this makes it
easier to experimentally find out which operations raise which
exceptions; e.g.:

>>> KeyboardInterrupt
'KeyboardInterrupt'
>>>

New argument passing semantics
------------------------------

Off-line discussions with Steve Majewski and Daniel LaLiberte have
convinced me that Python's parameter mechanism could be changed in a
way that made both of them happy (I hope), kept me happy, fixed a
number of outstanding problems, and, given some backward compatibility
provisions, would only break a very small amount of existing code --
probably all mine anyway. In fact I suspect that most Python users
will hardly notice the difference. And yet it has cost me at least
one sleepless night to decide to make the change...

Philosophically, the change is quite radical (to me, anyway): a
function is no longer called with either zero or one argument, which
is a tuple if there appear to be more arguments. Every function now
has an argument list containing 0, 1 or more arguments. This list is
always implemented as a tuple, and it is a (run-time) error if a
function is called with a different number of arguments than expected.

What's the difference? you may ask. The answer is, very little unless
you want to write variadic functions -- functions that may be called
with a variable number of arguments. Formerly, you could write a
function that accepted one or more arguments with little trouble, but
writing a function that could be called with either 0 or 1 argument
(or more) was next to impossible. This is now a piece of cake: you
can simply declare an argument that receives the entire argument
tuple, and check its length -- it will be of size 0 if there are no
arguments.

Another anomaly of the old system was the way multi-argument methods
(in classes) had to be declared, e.g.:

class Point():
def init(self, (x, y, color)): ...
def setcolor(self, color): ...
dev moveto(self, (x, y)): ...
def draw(self): ...

Using the new scheme there is no need to enclose the method arguments
in an extra set of parentheses, so the above class could become:

class Point:
def init(self, x, y, color): ...
def setcolor(self, color): ...
dev moveto(self, x, y): ...
def draw(self): ...

That is, the equivalence rule between methods and functions has
changed so that now p.moveto(x,y) is equivalent to Point.moveto(p,x,y)
while formerly it was equivalent to Point.moveto(p,(x,y)).

A special backward compatibility rule makes that the old version also
still works: whenever a function with exactly two arguments (at the top
level) is called with more than two arguments, the second and further
arguments are packed into a tuple and passed as the second argument.
This rule is invoked independently of whether the function is actually a
method, so there is a slight chance that some erroneous calls of
functions expecting two arguments with more than that number of
arguments go undetected at first -- when the function tries to use the
second argument it may find it is a tuple instead of what was expected.
Note that this rule will be removed from future versions of the
language; it is a backward compatibility provision *only*.

Two other rules and a new built-in function handle conversion between
tuples and argument lists:

Rule (a): when a function with more than one argument is called with a
single argument that is a tuple of the right size, the tuple's items
are used as arguments.

Rule (b): when a function with exactly one argument receives no
arguments or more than one, that one argument will receive a tuple
containing the arguments (the tuple will be empty if there were no
arguments).

While no new argument syntax was added in this phase, it would now be
quite sensible to add explicit syntax to Python for default argument
values (as in C++ or Modula-3), or a "rest" argument to receive the
remaining arguments of a variable-length argument list.

-------------------------------- PREFACE -------------------------------
This is Python release 0.9.4 alpha
==================================

What is Python?
---------------

Python is an interpreted prototyping language, incorporating modules,
exceptions, dynamic typing, very high level dynamic data types, and
classes. Python combines remarkable power with very clear syntax. It
has interfaces to many system calls and libraries, as well as to
various window systems, and is extensible in C. It is also usable as
an extension language for applications that need a programmable
interface. Finally, Python is portable: it runs on many brands of
UNIX, on the Mac, and maybe on MS-DOS.

About this release
------------------

Release 0.9.4:

- new function argument handling
- new exception string values (NameError = 'NameError' etc.)
- better checking for math exceptions
- for sequences (string/tuple/list), x[-i] is now equivalent to x[len(x)-i]
- fixed list assignment bug: "a[1:1] = a" now works correctly

Release 0.9.3:

Release 0.9.3 provides significant new functionality, improves
efficiency, fixes many bugs, and provides increased portability of the
Python interpreter. The syntax proper has changed only slightly since
0.9.2beta: a new reserved word, 'global', has been added, and there is
new syntax for specifying the base classes in a class declarations.

Highlights of new things in 0.9.3 since 0.9.2:

- string sys.version shows current version (also printed on interactive entry)
- more detailed exceptions, e.g., IOError, ZeroDivisionError, etc.
- 'global' statement to declare module-global variables assigned in functions.
- new class declaration syntax: class C(Base1, Base2, ...): suite
(the old syntax is still accepted -- be sure to convert your classes now!)
- C shifting and masking operators: << >> ~ & ^ | (for ints and longs).
- C comparison operators: == != (the old = and <> remain valid).
- floating point numbers may now start with a period (e.g., .14).
- definition of integer division tightened (always truncates towards zero).
- new builtins hex(x), oct(x) return hex/octal string from (long) integer.
- new list method l.count(x) returns the number of occurrences of x in l.
- new SGI module: al (Indigo and 4D/35 audio library).
- the FORMS interface (modules fl and FL) now uses FORMS 2.0
- module gl: added lrect{read,write}, rectzoom and pixmode;
added (non-GL) functions (un)packrect.
- new socket method: s.allowbroadcast(flag).
- many objects support __dict__, __methods__ or __members__.
- dir() lists anything that has __dict__.
- class attributes are no longer read-only.
- classes support __bases__, instances support __class__ (and __dict__).
- divmod() now also works for floats.
- fixed obscure bug in eval('1 ').

These features were new in version 0.9.2beta:

- tutorial now (almost) complete; library reference reorganized
- new syntax: continue statement; semicolons; dictionary constructors;
restrictions on blank lines in source files removed
- dramatically improved module load time through precompiled modules
- arbitrary precision integers: compute 2 to the power 1000 and more...
- arithmetic operators now accept mixed type operands, e.g., 3.14/4
- more operations on list: remove, index, reverse; repetition
- improved/new file operations: readlines, seek, tell, flush, ...
- process management added to the posix module: fork/exec/wait/kill etc.
- BSD socket operations (with example servers and clients!)
- many new STDWIN features (color, fonts, polygons, ...)
- new SGI modules: font manager and FORMS library interface

Release history
---------------

Version 0.9.0 was posted in February 1991 to alt.sources, soon
followed by patches to bring it up to level 0.9.1.

Compressed tar images of version 0.9.1 was made available for
anonymous ftp on several widely accessible US Internet sites, and in
Europe on hp4nl.nluug.nl and mcsun.eu.net. Since not everybody has
LaTeX, Postscript of the manuals documentation was also made available
in this way. Similar for a binhex'ed Macintosh application.

Release 0.9.2 never completely materialized, however a version called
0.9.2beta had limited distribution. (There was nothing wrong with it
except that I was too busy to release it after it went through beta
testing).

Ftp availability
----------------

I hope to make the compressed tar image of Python available for
anonymous ftp on at least the following sites (the filename being
python0.9.3.tar.Z):

site directory

ftp.cwi.nl pub (this is the master source)
wuarchive.wustl.edu pub
uunet.uu.net tmp

Notes for STDWIN users
----------------------

If you are using STDWIN with Python, you should fetch STDWIN 0.9.6,
available from the same sources as Python -- the new Python provides
interfaces to all the new STDWIN functionality so it won't link if you
use the old STDWIN library.

If you have applied the "unofficial patch" to stdwinmodule.c for the
Sun4 (inserting return keywords before calls to drawing_generic()),
you should unapply that patch, else the new patch may get in trouble.

Overview of this release
------------------------

Here is a summary of the most important user-visible changes in 0.9.2,
in somewhat arbitrary order. Changes in 0.9.3 are listed in the
"highlights" section above.

1. Changes to the interpreter proper

- Simple statements can now be separated by semicolons.
If you write "if t: s1; s2", both s1 and s2 are executed
conditionally.
- The 'continue' statement was added, with semantics as in C.
- Dictionary displays are now allowed on input: {key: value, ...}.
- Blank lines and lines bearing only a comment no longer need to
be indented properly. (A completely empty line still ends a multi-
line statement interactively.)
- Mixed arithmetic is supported, 1 compares equal to 1.0, etc.
- Option "-c command" to execute statements from the command line
- Compiled versions of modules are cached in ".pyc" files, giving a
dramatic improvement of start-up time
- Other, smaller speed improvements, e.g., extracting characters from
strings, looking up single-character keys, and looking up global
variables
- Interrupting a print operation raises KeyboardInterrupt instead of
only cancelling the print operation
- Fixed various portability problems (it now passes gcc with only
warnings -- more Standard C compatibility will be provided in later
versions)
- Source is prepared for porting to MS-DOS
- Numeric constants are now checked for overflow (this requires
standard-conforming strtol() and strtod() functions; a correct
strtol() implementation is provided, but the strtod() provided
relies on atof() for everything, including error checking

2. Changes to the built-in types, functions and modules

- New module socket: interface to BSD socket primitives
- New modules pwd and grp: access the UNIX password and group databases
- (SGI only:) New module "fm" interfaces to the SGI IRIX Font Manager
- (SGI only:) New module "fl" interfaces to Mark Overmars' FORMS library
- New numeric type: long integer, for unlimited precision
- integer constants suffixed with 'L' or 'l' are long integers
- new built-in function long(x) converts int or float to long
- int() and float() now also convert from long integers
- New built-in function:
- pow(x, y) returns x to the power y
- New operation and methods for lists:
- l*n returns a new list consisting of n concatenated copies of l
- l.remove(x) removes the first occurrence of the value x from l
- l.index(x) returns the index of the first occurrence of x in l
- l.reverse() reverses l in place
- New operation for tuples:
- t*n returns a tuple consisting of n concatenated copies of t
- Improved file handling:
- f.readline() no longer restricts the line length, is faster,
and isn't confused by null bytes; same for raw_input()
- f.read() without arguments reads the entire (rest of the) file
- mixing of print and sys.stdout.write() has different effect
- New methods for files:
- f.readlines() returns a list containing the lines of the file,
as read with f.readline()
- f.flush(), f.tell(), f.seek() call their stdio counterparts
- f.isatty() tests for "tty-ness"
- New posix functions:
- _exit(), exec(), fork(), getpid(), getppid(), kill(), wait()
- popen() returns a file object connected to a pipe
- utime() replaces utimes() (the latter is not a POSIX name)
- New stdwin features, including:
- font handling
- color drawing
- scroll bars made optional
- polygons
- filled and xor shapes
- text editing objects now have a 'settext' method

3. Changes to the standard library

- Name change: the functions path.cat and macpath.cat are now called
path.join and macpath.join
- Added new modules: formatter, mutex, persist, sched, mainloop
- Added some modules and functionality to the "widget set" (which is
still under development, so please bear with me):
DirList, FormSplit, TextEdit, WindowSched
- Fixed module testall to work non-interactively
- Module string:
- added functions join() and joinfields()
- fixed center() to work correct and make it "transitive"
- Obsolete modules were removed: util, minmax
- Some modules were moved to the demo directory

4. Changes to the demonstration programs

- Added new useful scipts: byteyears, eptags, fact, from, lfact,
objgraph, pdeps, pi, primes, ptags, which
- Added a bunch of socket demos
- Doubled the speed of ptags
- Added new stdwin demos: microedit, miniedit
- Added a windowing interface to the Python interpreter: python (most
useful on the Mac)
- Added a browser for Emacs info files: demo/stdwin/ibrowse
(yes, I plan to put all STDWIN and Python documentation in texinfo
form in the future)

5. Other changes to the distribution

- An Emacs Lisp file "pythonmode.el" is provided to facilitate editing
Python programs in GNU Emacs (slightly improved since posted to
gnu.emacs.sources)
- Some info on writing an extension in C is provided
- Some info on building Python on non-UNIX platforms is provided
------------------------------------------------------------------------

Happy hacking Christmas,

--Guido van Rossum, CWI, Amsterdam <guido@cwi.nl>
"Wenn ist das Nunnstueck git und Slotermeyer?"
"Ja! Beierhund das oder die flipperwaldt gersput."