Commit 6ca0c2e9 authored by Guido van Rossum's avatar Guido van Rossum

Initial revision

parent 11acc7f2
Acknowledgements
----------------
This list is not complete and not in any useful order, but I would
like to thank everybody who contributed in any way, with code, hints,
bug reports, ideas, moral support, endorsement, or even complaints....
Without you I would've stopped working on Python long ago!
--Guido
Amrit
Mark Anacker
Anthony Baxter
Donald Beaudry
Eric Beser
Stephen Bevan
Peter Bosch
Terrence Brannon
Erik de Bueger
Jan-Hein B"uhrman
Dick Bulterman
David Chaum
Jonathan Dasteel
John DeGood
Roger Dev
Lance Ellinghouse
Stoffel Erasmus
Niels Ferguson
Michael Guravage
Paul ten Hagen
Lynda Hardman
Ivan Herman
Chris Hoffman
Philip Homburg
Jack Jansen
Bill Janssen
Drew Jenkins
Lou Kates
Robert van Liere
Steve Majewski
Lambert Meertens
Steven Miale
Doug Moen
Sape Mullender
Sjoerd Mullender
George Neville-Neil
Randy Pausch
Marcel van der Peijl
Steven Pemberton
Tim Peters
John Redford
Timothy Roscoe
Kevin Samborn
Fred Sells
Denis Severson
Michael Shiplett
Paul Sijben
Dirk Soede
Per Spilling
Quentin Stafford-Fraser
Tracy Tims
Bennett Todd
Jaap Vermeulen
Dik Winter
[Excerpt from an email describing how to build Python on AIX.]
Subject: Re: Python 1.0.0 BETA 5 -- also for Macintosh!
From: se@MI.Uni-Koeln.DE (Stefan Esser)
To: Guido.van.Rossum@cwi.nl
Date: Fri, 7 Jan 1994 17:40:43 +0100
[...]
The following are [...] Instructions
to get a clean compile using gcc and xlc
under AIX 3.2.4.
Since I wanted to make sure that Python compiles
using both compilers and several sets of options
(ANSI and traditional C, optimize on/off) I didn't
try to include bash readline or other optional
modules.
'make test' succeeded using Python compiled with
the AIX C-compiler invoked as 'cc' and with options
'-o -qMEMMAX=4000' and compiled with 'gcc' and
options '-O -Wall'.
There were some problems trying to compile python
using 'gcc -ansi' (because of _AIX no longer being
defined), but I didn't have time to look into this.
Regards,
Stefan Esser
REQUIRED:
---------
1) AIX compilers don't like the LANG env
varaiable set to european locales.
This makes the compiler generate floating
point constants using "," as the decimal
seperator, which the assembler doesnt't
understand (or was it the other way around,
with the assembler expecting "," in float
numbers ???).
Anyway: "LANG=C; export LANG" solves the
problem, as does "LANG=C $(MAKE) ..." in
the master Makefile.
OPTIONAL:
---------
2) The xlc compiler considers "Python/ceval.c"
too complex to optimize, except when invoked
with "-qMEMMAX=4000".
[...]
What is Python?
---------------
Python is an interpreted, interactive, object-oriented programming
language. It incorporates 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 or 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 on
MS-DOS.
As a short example of what Python looks like, here's a script to
print prime numbers (not blazingly fast, but readable!). When this
file is made executable, it is callable directly from the UNIX shell
(if your system supports #! in scripts and the python interpreter is
installed at the indicated place).
#!/usr/local/bin/python
# Print prime numbers in a given range
def main():
import sys
min, max = 2, 0x7fffffff
if sys.argv[1:]:
min = int(eval(sys.argv[1]))
if sys.argv[2:]:
max = int(eval(sys.argv[2]))
primes(min, max)
def primes(min, max):
if 2 >= min: print 2
primes = [2]
i = 3
while i <= max:
for p in primes:
if i%p == 0 or p*p > i: break
if i%p <> 0:
primes.append(i)
if i >= min: print i
i = i+2
main()
Newsgroups: comp.lang.perl,comp.lang.tcl
From: lutz@xvt.com (Mark Lutz)
Subject: Python (was Re: Has anyone done a tk addition to perl?)
Organization: XVT Software Inc.
Date: Thu, 14 Oct 1993 17:10:37 GMT
X-Disclaimer: The views expressed in this message are those of an
individual at XVT Software Inc., and do not necessarily
reflect those of the company.
I've gotten a number of requests for information about Python,
since my post here earlier this week. Since this appears to be
of general interest, and since there's no python news group yet,
I'm posting a description here. I'm not the best authority on
the language, but here's my take on it.
[TCL/Perl zealots: this is informational only; I'm not trying to
'convert' anybody, and don't have time for a language war :-)
There is a paper comparing TCL/Perl/Python/Emacs-Lisp, which is
referenced in the comp.lang.misc faq, I beleive.]
What is Python?...
Python is a relatively new very-high-level language developed
in Amsterdam. Python is a simple, procedural language, with
features taken from ABC, Icon, Modula-3, and C/C++.
It's central goal is to provide the best of both worlds:
the dynamic nature of scripting languages like Perl/TCL/REXX,
but also support for general programming found in the more
traditional languages like Icon, C, Modula,...
As such, it can function as a scripting/extension language,
as a rapid prototyping language, and as a serious software
development language. Python is suitable for fast development
of large programs, but also does well at throw-away shell coding.
Python resembles other scripting languages a number of ways:
- dynamic, interpretive, interactive nature
- no explicit compile or link steps needed
- no type declarations (it's dynamically typed)
- high-level operators ('in', concatenation, etc)
- automatic memory allocation/deallocation (no 'pointers')
- high level objects: lists, tuples, strings, associative arrays
- programs can construct and execute program code using strings
- very fast edit/compile/run cycle; no static linking
- well-defined interface to and from C functions and data
- well-defined ways to add C modules to the system and language
Python's features that make it useful for serious programming:
- it's object-oriented; it has a simplified subset of
C++'s 'class' facility, made more useful by python's
dynamic typing; the language is object-oriented from
the ground up (rather than being an add-on, as in C++)
- it supports modules (imported packages, as in Modula-3);
modules replace C's 'include' files and linking, and allow
for multiple-module systems, code sharing, etc.;
- it has a good exception handling system (a 'try' statement,
and a 'raise' statement, with user-defined exceptions);
- it's orthogonal; everything is a first-class object in the
language (functions, modules, classes, class instance methods...)
and can be assigned/passed and used generically;
- it's fairly run-time secure; it does many run-time checks
like index-out-of-bounds, etc., that C usually doesn't;
- it has general data structuring support; Python lists are
heterogeneous, variable length, nestable, support slicing,
concatenation, etc., and come into existance and are reclaimed
automatically; strings and dictionaries are similarly general;
- it's got a symbolic debugger and profiler (written in python,
of course..), and an interactive command-line interface;
as in Lisp, you can enter code and test functions in isolation,
from the interactive command line (even linked C functions);
- it has a large library of built-in modules; it has support
for sockets, regular expressions, posix bindings, etc.
- it supports dynamic loading of C modules on many platforms;
- it has a _readable_ syntax; python code looks like normal
programming languages; tcl and perl can be very unreadable
(IMHO; what was that joke about Perl looking the same after
rot13..); python's syntax is simple, and statement based;
Of course, Python isn't perfect, but it's a good compromise betweem
scripting languages and traditional ones, and so is widely applicable.
'Perfect' languages aren't always useful for real-world tasks (Prolog,
for example), and languages at either extreme are not useful in the other
domain (C is poor for shell coding and prototyping, and awk is useless
for large systems design; Python does both well).
For example, I've used Python successfully for a 4K line expert system
shell project; it would have been at least twice as large in C, and would
have been very difficult in TCL or Perl.
Python uses an indentation-based syntax which may seem unusual at first
to C coders, but after using it I have found it to be _very_ handy, since
there's less to type. [I now forget to type '}' in my C code, and am
busy calculating how much time I wasted typing all those '}', 'END', etc.,
just to pander to 'brain-dead' C/Pascal compilers :-)].
Python's currently at release 0.9.9. It seems suprisingly stable.
The first 'official' 1.0 release is due out by the end of this year.
Python runs on most popular machines/systems (mac, dos, unix, etc.)
It's public domain and distributable, and can be had via ftp. The
distribution includes examples, tutorials, and documentation. The
latest ftp address I have (I got it on a cd-rom):
pub/python/* at ftp.cwi.nl
pub/? at wuarchive.wustl.edu (in america)
There's a python mailing list maintained by the language's creator.
Mail 'python-list-request@cwi.nl' to get on it.
Mark Lutz
lutz@xvt.com
Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
This diff is collapsed.
#! /usr/local/bin/python
import regex
import regsub
import glob
import sys
import os
import stat
import getopt
oldcprt = 'Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,\nAmsterdam, The Netherlands.'
newcprt = 'Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,\nAmsterdam, The Netherlands.'
oldprog = regex.compile(oldcprt)
newprog = regex.compile(newcprt)
def main():
opts, args = getopt.getopt(sys.argv[1:], 'y:')
agelimit = 0L
for opt, arg in opts:
if opt == '-y':
agelimit = os.stat(arg)[stat.ST_MTIME]
if not args:
args = glob.glob('*.[ch]')
for file in args:
try:
age = os.stat(file)[stat.ST_MTIME]
except os.error, msg:
print file, ': stat failed :', msg
continue
if age <= agelimit:
print file, ': too old, skipped'
continue
try:
f = open(file, 'r')
except IOError, msg:
print file, ': open failed :', msg
continue
head = f.read(1024)
if oldprog.search(head) < 0:
if newprog.search(head) < 0:
print file, ': NO COPYRIGHT FOUND'
else:
print file, ': (new copyright already there)'
f.close()
continue
newhead = regsub.sub(oldcprt, newcprt, head)
data = newhead + f.read()
f.close()
try:
f = open(file + '.new', 'w')
except IOError, msg:
print file, ': creat failed :', msg
continue
f.write(data)
f.close()
try:
os.rename(file, file + '~')
except IOError, msg:
print file, ': rename to backup failed :', msg
continue
try:
os.rename(file + '.new', file)
except IOError, msg:
print file, ': rename from .new failed :', msg
continue
print file, ': copyright changed.'
main()
This diff is collapsed.
all:
@echo Nothing to make in this directory.
clean:
find . '(' -name '*.pyc' -o -name core -o -name '*~' \
-o -name '[@,#]*' -o -name '*.old' \
-o -name '*.orig' -o -name '*.rej' ')' \
-print -exec rm -f {} ';'
clobber: clean
Python Misc subdirectory
========================
This directory contains files that wouldn't fit in elsewhere, in
particular the UNIX manual page, an Emacs mode for Python source code,
and a list of Frequently Asked Questions (and their answers).
Files found here
----------------
BLURB A quick description of Python for newcomers
BLURB.LUTZ A very good blurb to show to TCL/Perl hackers
COPYING The GNU GENERAL PUBLIC LICENCE (needed because of autoconf)
COPYRIGHT The Python copyright notice
FAQ Frequently Asked Questions about Python (and answers)
Fixcprt.py Fix the copyright message (a yearly chore :-)
README The file you're reading now
fixfuncptrs.sh Shell script to fix function pointer initializers
python-mode.el Emacs mode for editing Python programs (thanks again, Tim!)
python.man UNIX man page for the python interpreter
To: python-list
Subject: comp.lang.python RFD again
From: Guido.van.Rossum@cwi.nl
I've followed the recent discussion and trimmed the blurb RFD down a bit
(and added the word "object-oriented" to the blurb).
I don't think it's too early to *try* to create the newsgroup --
whether we will succeed may depend on how many Python supporters there
are outside the mailing list.
I'm personally not worried about moderation, and anyway I haven't
heard from any volunteers for moderation (and I won't volunteer
myself) so I suggest that we'll continue to ask for one unmoderated
newsgroup.
My next action will be to post an updated FAQ (which will hint at the
upcoming RFD) to comp.lang.misc; then finalize the 1.0.0 release and
put it on the ftp site. I'll also try to get it into
comp.sources.unix or .misc. And all this before the end of January!
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
URL: <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>
======================================================================
These are the steps required (in case you don't know about the
newsgroup creation process):
First, we need to draw up an RFD (Request For Discussion). This is a
document that tells what the purpose of the group is, and gives a case
for its creation. We post this to relevant groups (comp.lang.misc,
the mailing list, news.groups, etc.) Discussion is held on
news.groups.
Then, after a few weeks, we run the official CFV (Call For Votes).
The votes are then collected over a period of weeks. We need 100 more
yes votes than no votes, and a 2/3 majority, to get the group.
There are some restrictions on the vote taker: [s]he cannot actively
campaign for/against the group during the vote process. So the main
benefit to Steve instead of me running the vote is that I will be free
to campaign for its creation!
The following is our current draft for the RFD.
======================================================================
Request For Discussion: comp.lang.python
Purpose
-------
The newsgroup will be for discussion on the Python computer language.
Possible topics include requests for information, general programming,
development, and bug reports. The group will be unmoderated.
What is Python?
---------------
Python is a relatively new very-high-level language developed in
Amsterdam. Python is a simple, object-oriented procedural language,
with features taken from ABC, Icon, Modula-3, and C/C++.
Its central goal is to provide the best of both worlds: the dynamic
nature of scripting languages like Perl/TCL/REXX, but also support for
general programming found in the more traditional languages like Icon,
C, Modula,...
Python may be FTP'd from the following sites:
ftp.cwi.nl in directory /pub/python (its "home site", also has a FAQ)
ftp.uu.net in directory /languages/python
gatekeeper.dec.com in directory /pub/plan/python/cwi
Rationale
---------
Currently there is a mailing list with over 130 subscribers.
The activity of this list is high, and to make handling the
traffic more reasonable, a newsgroup is being proposed. We
also feel that comp.lang.misc would not be a suitable forum
for this volume of discussion on a particular language.
Charter
-------
Comp.lang.python is an unmoderated newsgroup which will serve
as a forum for discussing the Python computer language. The
group will serve both those who just program in Python and
those who work on developing the language. Topics that
may be discussed include:
- announcements of new versions of the language and
applications written in Python.
- discussion on the internals of the Python language.
- general information about the language.
- discussion on programming in Python.
Discussion
----------
Any objections to this RFD will be considered and, if determined
to be appropriate, will be incorporated. The discussion period
will be for a period of 21 days after which the first CFV will be
issued.
prog='
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*tp_dealloc\*/\)$|\1(destructor)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*tp_print\*/\)$|\1(printfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*tp_getattr\*/\)$|\1(getattrfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*tp_setattr\*/\)$|\1(setattrfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*tp_compare\*/\)$|\1(cmpfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*tp_repr\*/\)$|\1(reprfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*tp_hash\*/\)$|\1(hashfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*sq_length\*/\)$|\1(inquiry)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*sq_concat\*/\)$|\1(binaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*sq_repeat\*/\)$|\1(intargfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*sq_item\*/\)$|\1(intargfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*sq_slice\*/\)$|\1(intintargfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*sq_ass_item\*/\)$|\1(intobjargproc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*sq_ass_slice\*/\)$|\1(intintobjargproc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*mp_length\*/\)$|\1(inquiry)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*mp_subscript\*/\)$|\1(binaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*mp_ass_subscript\*/\)$|\1(objobjargproc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_nonzero*\*/\)$|\1(inquiry)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_coerce*\*/\)$|\1(coercion)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_negative*\*/\)$|\1(unaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_positive*\*/\)$|\1(unaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_absolute*\*/\)$|\1(unaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_invert*\*/\)$|\1(unaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_int*\*/\)$|\1(unaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_long*\*/\)$|\1(unaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_float*\*/\)$|\1(unaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_oct*\*/\)$|\1(unaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_hex*\*/\)$|\1(unaryfunc)\2 \3|
s|^\([ ]*\)\([a-z_]*,\)[ ]*\(/\*nb_[a-z]*\*/\)$|\1(binaryfunc)\2 \3|
'
for file
do
sed -e "$prog" $file >$file.new || break
if cmp -s $file $file.new
then
echo $file unchanged; rm $file.new
else
echo $file UPDATED
mv $file $file~
mv $file.new $file
fi
done
This diff is collapsed.
This diff was suppressed by a .gitattributes entry.
.TH PYTHON "3 January 1994"
.SH NAME
python \- an interpreted, interactive, object-oriented programming language
.SH SYNOPSIS
.B python
[
.I X11-options
]
[
.B \-d
]
[
.B \-i
]
[
.B \-k
]
[
.B \-v
]
[
.B \-c
.I command
|
.I script
|
\-
]
[
.I arguments
]
.SH DESCRIPTION
Python is an interpreted, interactive, object-oriented programming
language that combines remarkable power with very clear syntax.
For an introduction to programming in Python you are referred to the
Python Tutorial.
The Python Library Reference documents built-in and standard types,
constants, functions and modules.
Finally, the Python Reference Manual describes the syntax and
semantics of the core language in (perhaps too) much detail.
.PP
Python's basic power can be extended with your own modules written in
C or C++.
On some (most?) systems such modules may be dynamically loaded.
Python is also adaptable as an extension language for existing
applications.
See the internal documentation for hints.
.SH COMMAND LINE OPTIONS
.TP
.TP
.B \-d
Turn on parser debugging output (for wizards only, depending on
compilation options).
.B \-i
When a script is passed as first argument or the \fB\-c\fP option is
used, enter interactive mode after executing the script or the
command. This can be useful to inspect global variables or a stack
trace when a script raises an exception.
.TP
.B \-i
When executing a program from a file, this option enters interactive
mode after the program has completed. It does not read the
$PYTHONSTARTUP file.
.TP
.B \-k
This hack, eh, feature is intended to help you to find expression
statements that print a value. Although a feature of the language, it
can sometimes be annoying that when a function is called which returns
a value that is not
.IR None ,
the value is printed to standard output, and it is not always easy to
find which statement is the cause of an unwanted `1', for instance.
When this option is set, if an expression statement prints its value,
the exception
.I RuntimeError
is raised. The resulting stack trace will help you to track down the
culprit.
.TP
.B \-v
Print a message each time a module is initialized, showing the place
(filename or built-in module) from which it is loaded.
.TP
.BI "\-c " command
Specify the command to execute (see next section).
This terminates the option list (following options are passed as
arguments to the command).
.PP
When the interpreter is configured to contain the
.I stdwin
built-in module for use with the X window system, additional command
line options common to most X applications are recognized (by STDWIN),
e.g.
.B \-display
.I displayname
and
.B \-geometry
.I widthxheight+x+y.
The complete set of options is described in the STDWIN documentation.
.SH INTERPRETER INTERFACE
The interpreter interface resembles that of the UNIX shell: when
called with standard input connected to a tty device, it prompts for
commands and executes them until an EOF is read; when called with a
file name argument or with a file as standard input, it reads and
executes a
.I script
from that file;
when called with
.B \-c
.I command,
it executes the Python statement(s) given as
.I command.
Here
.I command
may contain multiple statements separated by newlines.
Leading whitespace is significant in Python statements!
In non-interactive mode, the entire input is parsed befored it is
executed.
.PP
If available, the script name and additional arguments thereafter are
passed to the script in the Python variable
.I sys.argv ,
which is a list of strings (you must first
.I import sys
to be able to access it).
If no script name is given,
.I sys.argv
is empty; if
.B \-c
is used,
.I sys.argv[0]
contains the string
.I '-c'.
Note that options interpreter by the Python interpreter or by STDWIN
are not placed in
.I sys.argv.
.PP
In interactive mode, the primary prompt is `>>>'; the second prompt
(which appears when a command is not complete) is `...'.
The prompts can be changed by assignment to
.I sys.ps1
or
.I sys.ps2.
The interpreter quits when it reads an EOF at a prompt.
When an unhandled exception occurs, a stack trace is printed and
control returns to the primary prompt; in non-interactive mode, the
interpreter exits after printing the stack trace.
The interrupt signal raises the
.I Keyboard\%Interrupt
exception; other UNIX signals are not caught (except that SIGPIPE is
sometimes ignored, in favor of the
.I IOError
exception). Error messages are written to stderr.
.SH FILES AND DIRECTORIES
These are subject to difference depending on local installation
conventions:
.IP /usr/local/bin/python
Recommended location of the interpreter.
.IP /usr/local/lib/python
Recommended location of the directory containing the standard modules.
.SH ENVIRONMENT VARIABLES
.IP PYTHONPATH
Augments the default search path for module files.
The format is the same as the shell's $PATH: one or more directory
pathnames separated by colons.
Non-existant directories are silently ignored.
The default search path is installation dependent, but always begins
with `.', (for example,
.I .:/usr/local/lib/python ).
The default search path is appended to $PYTHONPATH.
The search path can be manipulated from within a Python program as the
variable
.I sys.path .
.IP PYTHONSTARTUP
If this is the name of a readable file, the Python commands in that
file are executed before the first prompt is displayed in interactive
mode.
The file is executed in the same name space where interactive commands
are executed so that objects defined or imported in it can be used
without qualification in the interactive session.
You can also change the prompts
.I sys.ps1
and
.I sys.ps2
in this file.
.IP PYTHONDEBUG
If this is set to a non-empty string it is equivalent to specifying
the \fB\-d\fP option.
.IP PYTHONINSPECT
If this is set to a non-empty string it is equivalent to specifying
the \fB\-i\fP option.
.IP PYTHONKILLPRINT
If this is set to a non-empty string it is equivalent to specifying
the \fB\-k\fP option.
.IP PYTHONVERBOSE
If this is set to a non-empty string it is equivalent to specifying
the \fB\-v\fP option.
.SH SEE ALSO
Python Tutorial
.br
Python Library Reference
.br
Python Reference Manual
.br
STDWIN under X11
.SH BUGS AND CAVEATS
The first time
.I stdwin
is imported, it initializes the STDWIN library.
If this initialization fails, e.g. because the display connection
fails, the interpreter aborts immediately.
.SH AUTHOR
.nf
Guido van Rossum
CWI (Centrum voor Wiskunde en Informatica)
P.O. Box 4079
1009 AB Amsterdam
The Netherlands
.PP
E-mail: Guido.van.Rossum@cwi.nl
.fi
.SH MAILING LIST
There is a mailing list devoted to Python programming, bugs and
design.
To subscribe, send mail containing your real name and e-mail address
in Internet form to
.I python-list-request@cwi.nl.
.SH COPYRIGHT
Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
.IP " "
All Rights Reserved
.PP
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#! /usr/local/bin/python
# Renumber the Python FAQ
import string
import regex
import sys
import os
FAQ = 'FAQ'
chapterprog = regex.compile('^\([1-9][0-9]*\)\. ')
questionprog = regex.compile('^\([1-9][0-9]*\)\.\([1-9][0-9]*\)\. ')
newquestionprog = regex.compile('^Q\. ')
blankprog = regex.compile('^[ \t]*$')
indentedorblankprog = regex.compile('^\([ \t]+\|[ \t]*$\)')
def main():
print 'Reading lines...'
lines = open(FAQ, 'r').readlines()
print 'Renumbering in memory...'
oldlines = lines[:]
after_blank = 1
chapter = 0
question = 0
chapters = ['\n']
questions = []
for i in range(len(lines)):
line = lines[i]
if after_blank:
n = chapterprog.match(line)
if n >= 0:
chapter = chapter + 1
question = 0
line = `chapter` + '. ' + line[n:]
lines[i] = line
chapters.append(' ' + line)
questions.append('\n')
questions.append(' ' + line)
afterblank = 0
continue
n = questionprog.match(line)
if n < 0: n = newquestionprog.match(line) - 3
if n >= 0:
question = question + 1
line = '%d.%d. '%(chapter, question) + line[n:]
lines[i] = line
questions.append(' ' + line)
# Add up to 4 continuations of the question
for j in range(i+1, i+5):
if blankprog.match(lines[j]) >= 0:
break
questions.append(' '*(n+2) + lines[j])
afterblank = 0
continue
afterblank = (blankprog.match(line) >= 0)
print 'Inserting list of chapters...'
chapters.append('\n')
for i in range(len(lines)):
line = lines[i]
if regex.match(
'^This FAQ is divided in the following chapters',
line) >= 0:
i = i+1
while 1:
line = lines[i]
if indentedorblankprog.match(line) < 0:
break
del lines[i]
lines[i:i] = chapters
break
else:
print '*** Can\'t find header for list of chapters'
print '*** Chapters found:'
for line in chapters: print line,
print 'Inserting list of questions...'
questions.append('\n')
for i in range(len(lines)):
line = lines[i]
if regex.match('^Here.s an overview of the questions',
line) >= 0:
i = i+1
while 1:
line = lines[i]
if indentedorblankprog.match(line) < 0:
break
del lines[i]
lines[i:i] = questions
break
else:
print '*** Can\'t find header for list of questions'
print '*** Questions found:'
for line in questions: print line,
if lines == oldlines:
print 'No changes.'
return
print 'Writing new file...'
f = open(FAQ + '.new', 'w')
for line in lines:
f.write(line)
f.close()
print 'Making backup...'
os.rename(FAQ, FAQ + '~')
print 'Moving new file...'
os.rename(FAQ + '.new', FAQ)
print 'Done.'
main()
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