mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Initial revision
This commit is contained in:
parent
8f0d0c8a21
commit
a7925f18de
16 changed files with 4571 additions and 0 deletions
64
Misc/ACKS
Normal file
64
Misc/ACKS
Normal file
|
@ -0,0 +1,64 @@
|
|||
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
|
61
Misc/AIX-NOTES
Normal file
61
Misc/AIX-NOTES
Normal file
|
@ -0,0 +1,61 @@
|
|||
[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".
|
||||
|
||||
[...]
|
45
Misc/BLURB
Normal file
45
Misc/BLURB
Normal file
|
@ -0,0 +1,45 @@
|
|||
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()
|
122
Misc/BLURB.LUTZ
Normal file
122
Misc/BLURB.LUTZ
Normal file
|
@ -0,0 +1,122 @@
|
|||
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
|
20
Misc/COPYRIGHT
Normal file
20
Misc/COPYRIGHT
Normal file
|
@ -0,0 +1,20 @@
|
|||
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.
|
643
Misc/FAQ
Normal file
643
Misc/FAQ
Normal file
|
@ -0,0 +1,643 @@
|
|||
Subject: FAQ: Python -- an object-oriented language
|
||||
Newsgroups: comp.lang.misc,comp.answers,news.answers
|
||||
Followup-to: comp.lang.misc
|
||||
From: guido@cwi.nl (Guido van Rossum)
|
||||
Reply-to: guido@cwi.nl (Guido van Rossum)
|
||||
Approved: news-answers-request@MIT.Edu
|
||||
|
||||
Archive-name: python-faq/part1
|
||||
Version: 1.2
|
||||
Last-modified: 24 Jan 1994
|
||||
|
||||
This article contains answers to Frequently Asked Questions about
|
||||
Python (an object-oriented interpreted programming language -- see
|
||||
the answer to question 1.1 for a short overview).
|
||||
|
||||
Copyright 1993, 1994 Guido van Rossum. Unchanged electronic
|
||||
redistribution of this FAQ is allowed. Printed redistribution only
|
||||
with permission of the author. No warranties.
|
||||
|
||||
Author's address:
|
||||
Guido van Rossum
|
||||
CWI, dept. CST
|
||||
Kruislaan 413
|
||||
P.O. Box 94079
|
||||
1090 GB Amsterdam
|
||||
The Netherlands
|
||||
Email: guido@cwi.nl
|
||||
|
||||
The latest version of this FAQ is available by anonymous ftp from
|
||||
ftp.cwi.nl [192.16.184.180] in the directory /pub/python, with
|
||||
filename python-FAQ. It will also be posted regularly to the
|
||||
newsgroups comp.answers and comp.lang.misc.
|
||||
|
||||
Many FAQs, including this one, are available by anonymous ftp from
|
||||
rtfm.mit.edu [18.70.0.209] in the directory pub/usenet/news.answers.
|
||||
The name under which a FAQ is archived appears in the Archive-name line
|
||||
at the top of the article. This FAQ is archived as python-faq/part1.
|
||||
|
||||
There's a mail server on that machine which will send you files from
|
||||
the archive by e-mail if you have no ftp access. You send a e-mail
|
||||
message to mail-server@rtfm.mit.edu containing the single word help in
|
||||
the message body to receive instructions.
|
||||
|
||||
This FAQ is divided in the following chapters:
|
||||
|
||||
1. General information and availability
|
||||
2. Python in the real world
|
||||
3. Building Python
|
||||
4. Programming in Python
|
||||
5. Extending Python
|
||||
6. Python's design
|
||||
7. Using Python on non-UNIX platforms
|
||||
|
||||
To find the start of a particular chapter, search for the chapter number
|
||||
followed by a dot and a space at the beginning of a line (e.g. to
|
||||
find chapter 4 in vi, type /^4\. /).
|
||||
|
||||
Here's an overview of the questions per chapter:
|
||||
|
||||
1. General information and availability
|
||||
1.1. Q. What is Python?
|
||||
1.2. Q. Why is it called Python?
|
||||
1.3. Q. How do I obtain a copy of the Python source?
|
||||
1.4. Q. How do I get documentation on Python?
|
||||
1.5. Q. Is there a newsgroup or mailing list devoted to Python?
|
||||
1.6. Q. Is there a book on Python, or will there be one out soon?
|
||||
1.7. Q. Are there any published articles about Python that I can quote?
|
||||
|
||||
2. Python in the real world
|
||||
2.1. Q. How many people are using Python?
|
||||
2.2. Q. Have any significant projects been done in Python?
|
||||
2.3. Q. Are there any commercial projects going on using Python?
|
||||
2.4. Q. What new developments are expected for Python in the future?
|
||||
2.5. Q. How stable is Python?
|
||||
2.6. Q. Any more future plans?
|
||||
|
||||
3. Building Python
|
||||
3.1. Q. I have trouble building the md5 module and/or finding the file
|
||||
md5.c.
|
||||
3.2. Q. Is there a test set?
|
||||
3.3. Q. When running the test set, I get complaints about floating point
|
||||
operations, but when playing with floating point operations I cannot
|
||||
find anything wrong with them.
|
||||
3.4. Q. I get an OverflowError on evaluating 2*2. What is going on?
|
||||
3.5. Q. Trouble building Python 0.9.9 on platform X.
|
||||
|
||||
4. Programming in Python
|
||||
4.1. Q. Can I create an object class with some methods implemented in
|
||||
C and others in Python (e.g. through inheritance)? (Also phrased as:
|
||||
Can I use a built-in type as base class?)
|
||||
4.2. Q. I assign to a variable in a call to exec() but when I try to
|
||||
use it on the next line I get an error. What is going on?
|
||||
4.3. Q. Why does that work?
|
||||
4.4. Q. Is there a curses/termcap package for Python?
|
||||
4.5. Q. Is there an equivalent to C's onexit() in Python?
|
||||
4.6. Q. When I define a function nested inside another function, the
|
||||
nested function seemingly can't access the local variables of the
|
||||
outer function. What is going on? How do I pass local data to a
|
||||
nested function?
|
||||
4.7. Q. How do I iterate over a sequence in reverse order?
|
||||
4.8. Q. My program is too slow. How do I speed it up?
|
||||
4.9. Q. When I have imported a module, then edit it, and import it
|
||||
again (into the same Python process), the changes don't seem to take
|
||||
place. What is going on?
|
||||
|
||||
5. Extending Python
|
||||
5.1. Q. Can I create my own functions in C?
|
||||
5.2. Q. Can I create my own functions in C++?
|
||||
|
||||
6. Python's design
|
||||
6.1. Q. Why isn't there a generic copying operation for objects in
|
||||
Python?
|
||||
6.2. Q. Why isn't there a generic way to implement persistent objects
|
||||
in Python? (Persistent == automatically saved to and restored from
|
||||
disk.)
|
||||
6.3. Q. Why isn't there a switch or case statement in Python?
|
||||
|
||||
7. Using Python on non-UNIX platforms
|
||||
7.1. Q. Where's the DOS version of 0.9.9?
|
||||
7.2. Q. Is there a Windows version of Python?
|
||||
7.3. Q. I have the Mac or DOS version but it appears to be only a binary.
|
||||
Where's the library?
|
||||
7.4. Q. Where's the documentation for the Mac or DOS version?
|
||||
7.5. Q. The Mac version doesn't seem to have any facilities for creating or
|
||||
editing programs apart from entering it interactively, and there seems
|
||||
to be no way to save code that was entered interactively. How do I
|
||||
create a Python program on the Mac?
|
||||
|
||||
To find a particular question, search for the question number followed
|
||||
by a dot, a space, and a Q at the beginning of a line (e.g. to find
|
||||
question 4.2 in vi, type /^4\.2\. Q/).
|
||||
|
||||
|
||||
1. General information and availability
|
||||
=======================================
|
||||
|
||||
1.1. Q. What is Python?
|
||||
|
||||
A. 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.
|
||||
|
||||
To find out more, the best thing to do is to start reading the
|
||||
tutorial from the documentation set (see a few questions further
|
||||
down).
|
||||
|
||||
1.2. Q. Why is it called Python?
|
||||
|
||||
A. Apart from being a computer wizard, I'm also a fan of "Monty
|
||||
Python's Flying Circus" (a BBC comedy series from the seventies, in
|
||||
case you didn't know). It occurred to me one day that I needed a name
|
||||
that was short, unique, and slightly mysterious. And I happened to be
|
||||
reading some scripts from the series at the time... So then I decided
|
||||
to call my language Python. But Python is not a joke. And don't you
|
||||
associate it with dangerous reptiles either!
|
||||
|
||||
1.3. Q. How do I obtain a copy of the Python source?
|
||||
|
||||
A. The latest Python source distribution is always available by
|
||||
anonymous ftp from ftp.cwi.nl [192.16.184.180] in the directory
|
||||
/pub/python, with filename python<version>.tar.Z. It is a compressed
|
||||
tar file containing the complete C source, LaTeX documentation, Python
|
||||
library modules, example programs, and several useful pieces of freely
|
||||
distributable software. This will compile and run out of the box on
|
||||
most UNIX platforms. Currently <version> is 0.9.9. (See section 7
|
||||
for non-UNIX information.)
|
||||
|
||||
1.4. Q. How do I get documentation on Python?
|
||||
|
||||
A. The latest Python documentation set is always available by
|
||||
anonymous ftp from ftp.cwi.nl [192.16.184.180] in the directory
|
||||
/pub/python, with filename pythondoc-ps<version>.tar.Z. It is a
|
||||
compressed tar file containing PostScript files of the reference
|
||||
manual, the library manual, and the tutorial. Currently <version> is
|
||||
0.9.9. (Note that the library manual is the most important one of the
|
||||
set, as much of Python's power stems from the standard or built-in
|
||||
types, functions and modules, all of which are described here.)
|
||||
PostScript for a high-level description of Python is in the file
|
||||
nluug-paper.ps.
|
||||
|
||||
The following sites keep mirrors of the Python distribution:
|
||||
|
||||
Site IP address Directory
|
||||
|
||||
gatekeeper.dec.com 16.1.0.2 /pub/plan/python/cwi
|
||||
ftp.uu.net 192.48.96.9 /languages/python
|
||||
ftp.wustl.edu 128.252.135.4 /graphics/graphics/sgi-stuff/python
|
||||
ftp.funet.fi 128.214.6.100 /pub/languages/python (old?)
|
||||
ftp.fu-berlin.de 130.133.4.50 /pub/unix/languages/python (python* only)
|
||||
|
||||
Or try archie on e.g. python0.9.9.tar.Z to locate the nearest copy of
|
||||
that version...
|
||||
|
||||
1.5. Q. Is there a newsgroup or mailing list devoted to Python?
|
||||
|
||||
A. There is no Python newsgroup yet; if you want to post to the net
|
||||
about Python, use comp.lang.misc. There is a mailing list devoted to
|
||||
Python; send e-mail to python-list-request@cwi.nl to (un)subscribe.
|
||||
There are plans to start the discussion about creation of
|
||||
comp.lang.python as soon as version 1.0.0 has been released.
|
||||
|
||||
1.6. Q. Is there a book on Python, or will there be one out soon?
|
||||
|
||||
A. Unfortunately, not yet. I would like to write one but my
|
||||
obligations at CWI include too much other work to make much progress
|
||||
on it. Several parties have expressed interest in sponsoring or
|
||||
helping the production of a book or reference manual, but so far there
|
||||
are no firm plans. If you volunteer help, by all means drop me a
|
||||
note!
|
||||
|
||||
1.7. Q. Are there any published articles about Python that I can quote?
|
||||
|
||||
A. So far the only refereed and published article that describes
|
||||
Python in some detail is:
|
||||
|
||||
Guido van Rossum and Jelke de Boer, "Interactively Testing Remote
|
||||
Servers Using the Python Programming Language", CWI Quarterly, Volume
|
||||
4, Issue 4 (December 1991), Amsterdam, pp 283-303.
|
||||
|
||||
LaTeX source for this paper is available as part of the Python source
|
||||
distribution.
|
||||
|
||||
A more recent high-level description of Python is:
|
||||
|
||||
Guido van Rossum, "An Introduction to Python for UNIX/C
|
||||
Programmers", in the proceedings of the NLUUG najaarsconferentie
|
||||
1993 (dutch UNIX users group meeting november 1993).
|
||||
|
||||
PostScript for this paper and for the slides used for the accompanying
|
||||
presentation can be found in the ftp directory mentioned a few
|
||||
questions earlier, with filenames nluug-paper.ps and nluug-slides.ps,
|
||||
respectively.
|
||||
|
||||
|
||||
2. Python in the real world
|
||||
===========================
|
||||
|
||||
2.1. Q. How many people are using Python?
|
||||
|
||||
A. I don't know, but at the last count there were at least 130
|
||||
addresses on the Python mailing list (several of which are local
|
||||
redistribution lists). I suspect that many users don't bother
|
||||
to subscribe to the list.
|
||||
|
||||
2.2. Q. Have any significant projects been done in Python?
|
||||
|
||||
A. Here at CWI (the home of Python), we have written a 20,000 line
|
||||
authoring environment for transportable hypermedia presentations, a
|
||||
multimedia teleconferencing tool, as well as many smaller programs.
|
||||
|
||||
The University of Virginia uses Python to control a virtual reality
|
||||
engine. Contact: Matt Conway <conway@virginia.edu>.
|
||||
|
||||
See also the next question.
|
||||
|
||||
2.3. Q. Are there any commercial projects going on using Python?
|
||||
|
||||
A. Several companies have revealed to me that they are planning or
|
||||
considering to use Python in a future product. The furthest is
|
||||
Sunrise Software, who already have a product out using Python -- they
|
||||
use Python for a GUI management application and an SNMP network
|
||||
manangement application. Contact: <info@sunrise.com>.
|
||||
|
||||
Individuals at many other companies are using Python for
|
||||
internal development (witness their contributions to the Python
|
||||
mailing list).
|
||||
|
||||
Python has also been elected as an extension language by MADE, a
|
||||
consortium supported by the European Committee's ESPRIT program and
|
||||
consisting of Bull, CWI and some other European companies. Contact:
|
||||
Ivan Herman <ivan@cwi.nl>.
|
||||
|
||||
2.4. Q. What new developments are expected for Python in the future?
|
||||
|
||||
A. I am almost ready to release version 1.0.0 -- it should be out by
|
||||
the end of January 1994. It will have some new functionality and
|
||||
bugfixes and be portable to more platforms. The directory tree
|
||||
structure and build procedure will be radically different -- almost
|
||||
all configuration is now done automatically, using GNU autoconf.
|
||||
User-visible changes include: double-quoted strings, functional
|
||||
programming operations (lambda, map, filter, reduce -- all evaluated
|
||||
eagerly), exec becomes a statement, str() is customizable through
|
||||
__str__ (used by print). The originally planned grand renaming scheme
|
||||
will not be implemented because of lack of time. A beta version can
|
||||
be ftp'ed from the usual sites, file python1.0.0beta.tar.Z.
|
||||
|
||||
2.5. Q. How stable is Python?
|
||||
|
||||
A. Very stable. While the current version number (0.9.9) would
|
||||
suggest it is in the early stages of development, in fact new, stable
|
||||
releases have been coming out every 3-6 months for the past three years.
|
||||
|
||||
2.6. Q. Any more future plans?
|
||||
|
||||
A. Without warranty that any of this will actually be realized: I am
|
||||
currently thinking about mechanisms for built-in on-line help and a
|
||||
switch/case statement. There are also some people (independently)
|
||||
working on a windowing interface based on STDWIN but with the power
|
||||
and ease of use of the average modern widget set. I still hope to get
|
||||
some help in producing a Windows version. It would be nice if there
|
||||
were a window-based class browser (Someone at CWI has contributed one
|
||||
using Motif but it needs some work).
|
||||
|
||||
|
||||
3. Building Python
|
||||
==================
|
||||
|
||||
3.1. Q. I have trouble building the md5 module and/or finding the file
|
||||
md5.c.
|
||||
|
||||
A. Apparently the md5 module was based on an older version of RSA's
|
||||
md5 implementation. The ftp site rsa.com mentioned in the Makefile
|
||||
where this version was found is no longer accessible, and the version
|
||||
from RFC 1321 (md5c.c) is slightly different. This will be fixed in
|
||||
the 1.0 release; write me if you need the fixes now.
|
||||
|
||||
3.2. Q. Is there a test set?
|
||||
|
||||
A. Yes, simply do "import testall" (or "import autotest" if you aren't
|
||||
interested in the output). The standard modules whose name begins
|
||||
with "test" together comprise the test. The test set doesn't test
|
||||
*all* features of Python but it goes a long way to confirm that a new
|
||||
port is actually working. The Makefile contains an entry "make test"
|
||||
which runs the autotest module.
|
||||
|
||||
3.3. Q. When running the test set, I get complaints about floating point
|
||||
operations, but when playing with floating point operations I cannot
|
||||
find anything wrong with them.
|
||||
|
||||
A. The test set makes occasional unwarranted assumptions about the
|
||||
semantics of C floating point operations. Until someone donates a
|
||||
better floating point test set, you will have to comment out the
|
||||
offending floating point tests and execute similar tests manually.
|
||||
|
||||
3.4. Q. I get an OverflowError on evaluating 2*2. What is going on?
|
||||
|
||||
A. Your machine probably has 64 bit long integers (e.g. DEC alpha or
|
||||
HP snake architectures). There are some dependencies on word length
|
||||
in file intobject.c. This will be corrected in the 1.0 release; until
|
||||
then, on a 64 bit machine, just comment out the check for overflow
|
||||
from int_mul:
|
||||
|
||||
#if 0
|
||||
if (x > 0x7fffffff || x < (double) (long) 0x80000000)
|
||||
return err_ovf("integer multiplication");
|
||||
#endif
|
||||
|
||||
You should also include <limits.h> and replace the constant 32 by
|
||||
LONG_BIT in int_[lr]shift.
|
||||
|
||||
3.5. Q. Trouble building Python 0.9.9 on platform X.
|
||||
|
||||
A. In the bootstrap phase (before you have built the first running
|
||||
interpreter), make sure the -D settings in the Makefile are correct
|
||||
for your system. In particular you may have to add or delete -DSYSV.
|
||||
It may also be necessary to change the flags used to compile
|
||||
posixmodule.c and timemodule.c; e.g. on AIX the following are
|
||||
necessary:
|
||||
posixmodule.c: -DHAVE_STDLIB -DNOALTTZ -DOLDTZ -Dunix -DSYSV -DDO_TIMES
|
||||
timemodule.c: -DHAVE_STDLIB -DNOALTTZ -DOLDTZ -Uunix -DSYSV -DBSD_TIME
|
||||
(Note the -Uunix for timemodule!)
|
||||
Those switches for timemodule also require that the
|
||||
#ifdef unix
|
||||
#ifdef BSD_TIME
|
||||
just above:
|
||||
static long
|
||||
millitimer()
|
||||
( and below the "#endif /* macintosh */" version of millitimer
|
||||
be changed to:
|
||||
#if defined(unix) | defined(BSD_TIME)
|
||||
#ifdef BSD_TIME
|
||||
|
||||
|
||||
4. Programming in Python
|
||||
========================
|
||||
|
||||
4.1. Q. Can I create an object class with some methods implemented in
|
||||
C and others in Python (e.g. through inheritance)? (Also phrased as:
|
||||
Can I use a built-in type as base class?)
|
||||
|
||||
A. No, but you can easily create a Python class which serves as a
|
||||
wrapper around a built-in object, e.g. (for dictionaries):
|
||||
|
||||
# A user-defined class behaving almost identical
|
||||
# to a built-in dictionary.
|
||||
class UserDict:
|
||||
def __init__(self): self.data = {}
|
||||
def __repr__(self): return repr(self.data)
|
||||
def __cmp__(self, dict):
|
||||
if type(dict) == type(self.data):
|
||||
return cmp(self.data, dict)
|
||||
else:
|
||||
return cmp(self.data, dict.data)
|
||||
def __len__(self): return len(self.data)
|
||||
def __getitem__(self, key): return self.data[key]
|
||||
def __setitem__(self, key, item): self.data[key] = item
|
||||
def __delitem__(self, key): del self.data[key]
|
||||
def keys(self): return self.data.keys()
|
||||
def items(self): return self.data.items()
|
||||
def values(self): return self.data.values()
|
||||
def has_key(self, key): return self.data.has_key(key)
|
||||
|
||||
4.2. Q. I assign to a variable in a call to exec() but when I try to
|
||||
use it on the next line I get an error. What is going on?
|
||||
|
||||
A. The reason why this occurs is too complicated to explain (but see
|
||||
the next question). To fix it is easy, however: simply assign None to
|
||||
the variable *before* calling exec(). This will be fixed in the 1.0
|
||||
release.
|
||||
|
||||
4.3. Q. Why does that work?
|
||||
|
||||
A. When parsing your program and converting it into internal pseudo
|
||||
code, the interpreter does some optimizations to speed up function
|
||||
execution: it figures out the names of all the local variables and
|
||||
treats them specially. Because your assignment is done by exec(), it
|
||||
is not seen initially by the parser and the variable is not recognized
|
||||
as a local variable. The default treatment is as a global variable,
|
||||
but the exec() statement places it in the local scope, where it is not
|
||||
found. This will be fixed in release 1.0 by making exec into a
|
||||
statement; the parser will then be able to switch off the
|
||||
optimizations for local variables if it encounters an exec statement
|
||||
(recognizing calls to built-in functions is not possible for the
|
||||
parser, hence the syntax change to a statement).
|
||||
|
||||
4.4. Q. Is there a curses/termcap package for Python?
|
||||
|
||||
A. No, but you can use the "alfa" (== character cell) version of
|
||||
STDWIN. (STDWIN == Standard Windows, a portable windowing system
|
||||
interface by the same author, URL ftp://ftp.cwi.nl/pub/stdwin.)
|
||||
This will also prepare your program for porting to windowing
|
||||
environments such as X11 or the Macintosh.
|
||||
|
||||
4.5. Q. Is there an equivalent to C's onexit() in Python?
|
||||
|
||||
A. Yes, if you import sys and assign a function to sys.exitfunc, it
|
||||
will be called when your program exits, is killed by an unhandled
|
||||
exception, or (on UNIX) receives a SIGHUP or SIGTERM signal.
|
||||
|
||||
4.6. Q. When I define a function nested inside another function, the
|
||||
nested function seemingly can't access the local variables of the
|
||||
outer function. What is going on? How do I pass local data to a
|
||||
nested function?
|
||||
|
||||
A. Python does not have arbitrarily nested scopes. When you need to
|
||||
create a function that needs to access some data which you have
|
||||
available locally, create a new class to hold the data and return a
|
||||
method of an instance of that class, e.g.:
|
||||
|
||||
class MultiplierClass:
|
||||
def __init__(self, factor):
|
||||
self.factor = factor
|
||||
def multiplier(self, argument):
|
||||
return argument * self.factor
|
||||
|
||||
def generate_multiplier(factor):
|
||||
return MultiplierClass(factor).multiplier
|
||||
|
||||
twice = generate_multiplier(2)
|
||||
print twice(10)
|
||||
# Output: 20
|
||||
|
||||
4.7. Q. How do I iterate over a sequence in reverse order?
|
||||
|
||||
A. If it is a list, the fastest solution is
|
||||
|
||||
list.reverse()
|
||||
try:
|
||||
for x in list:
|
||||
"do something with x"
|
||||
finally:
|
||||
list.reverse()
|
||||
|
||||
This has the disadvantage that while you are in the loop, the list
|
||||
is temporarily reversed. If you don't like this, you can make a copy.
|
||||
This appears expensive but is actually faster than other solutions:
|
||||
|
||||
rev = list[:]
|
||||
rev.reverse()
|
||||
for x in rev:
|
||||
<do something with x>
|
||||
|
||||
If it isn't a list, a more general but slower solution is:
|
||||
|
||||
i = len(list)
|
||||
while i > 0:
|
||||
i = i-1
|
||||
x = list[i]
|
||||
<do something with x>
|
||||
|
||||
A more elegant solution, is to define a class which acts as a sequence
|
||||
and yields the elements in reverse order (solution due to Steve
|
||||
Majewski):
|
||||
|
||||
class Rev:
|
||||
def __init__(self, seq):
|
||||
self.forw = seq
|
||||
def __len__(self):
|
||||
return len(self.forw)
|
||||
def __getitem__(self, i):
|
||||
return self.forw[-(i + 1)]
|
||||
|
||||
You can now simply write:
|
||||
|
||||
for x in Rev(list):
|
||||
<do something with x>
|
||||
|
||||
Unfortunately, this solution is slowest of all, due the the method
|
||||
call overhead...
|
||||
|
||||
4.8. Q. My program is too slow. How do I speed it up?
|
||||
|
||||
A. That's a tough one, in general. There are many tricks to speed up
|
||||
Python code; I would consider rewriting parts in C only as a last
|
||||
resort. One thing to notice is that function and (especially) method
|
||||
calls are rather expensive; if you have designed a purely OO interface
|
||||
with lots of tiny functions that don't do much more than get or set an
|
||||
instance variable or call another method, you may consider using a
|
||||
more direct way, e.g. directly accessing instance variables. Also see
|
||||
the standard module "profile" (described in the file
|
||||
"python/lib/profile.doc") which makes it possible to find out where
|
||||
your program is spending most of its time (if you have some patience
|
||||
-- the profiling itself can slow your program down by an order of
|
||||
magnitude).
|
||||
|
||||
4.9. Q. When I have imported a module, then edit it, and import it
|
||||
again (into the same Python process), the changes don't seem to take
|
||||
place. What is going on?
|
||||
|
||||
A. For efficiency reasons, Python only reads the module file on the
|
||||
first time a module is imported (otherwise a program consisting of
|
||||
many modules, each of which imports the same basic module, would read
|
||||
the basic module over and over again). To force a changed module
|
||||
being read again, do this:
|
||||
|
||||
import modname
|
||||
reload(modname)
|
||||
|
||||
Warning: this technique is not 100% fool-proof. In particular,
|
||||
modules containing statements like
|
||||
|
||||
from modname import some_objects
|
||||
|
||||
will continue to work with the old version of the objects imported
|
||||
thus.
|
||||
|
||||
|
||||
5. Extending Python
|
||||
===================
|
||||
|
||||
5.1. Q. Can I create my own functions in C?
|
||||
|
||||
A. Yes, you can create built-in modules containing functions,
|
||||
variables, exceptions and even new types in C. This is all explained
|
||||
in the file "python/misc/EXTENDING". Also read the file "DYNLOAD"
|
||||
there for hints on how to load such extension modules
|
||||
|
||||
5.2. Q. Can I create my own functions in C++?
|
||||
|
||||
A. Yes, using the C-compatibility features found in C++. Basically
|
||||
you place extern "C" { ... } around the Python include files and put
|
||||
extern "C" before each function that is going to be called by the
|
||||
Python interpreter. Global or static C++ objects with constructors
|
||||
are probably not a good idea.
|
||||
|
||||
|
||||
6. Python's design
|
||||
==================
|
||||
|
||||
6.1. Q. Why isn't there a generic copying operation for objects in
|
||||
Python?
|
||||
|
||||
A. Hmm. Maybe there should be one, but it's difficult to assign a
|
||||
useful meaning to copying of open files, sockets and windows, or
|
||||
recursive data structures. As long as you design all your classes
|
||||
yourself you are of course free to define a standard base class that
|
||||
defines an overridable copying operation for all the objects you care
|
||||
about. (One practical point: it would have to be a built-in function,
|
||||
not a standard method name, since not all built-in object types have
|
||||
methods; e.g. strings, integers and tuples don't.)
|
||||
|
||||
6.2. Q. Why isn't there a generic way to implement persistent objects
|
||||
in Python? (Persistent == automatically saved to and restored from
|
||||
disk.)
|
||||
|
||||
A. Hmm, hmm. Basically for the same reasons as why there is no
|
||||
generic copying operation.
|
||||
|
||||
6.3. Q. Why isn't there a switch or case statement in Python?
|
||||
|
||||
A. You can do this easily enough with a sequence of
|
||||
if... elif... elif... else. There have been some proposals for switch
|
||||
statement syntax, but there is no concensus (yet) on whether and how
|
||||
to do range tests.
|
||||
|
||||
|
||||
7. Using Python on non-UNIX platforms
|
||||
=====================================
|
||||
|
||||
7.1. Q. Where's the DOS version of 0.9.9?
|
||||
|
||||
A. I hope it will be coming soon. A friend with a DOS machine and a
|
||||
compiler has volunteered to build it but he's very busy. Until then,
|
||||
you will have to make do with the 0.9.8 version (which isn't so bad,
|
||||
actually).
|
||||
|
||||
7.2. Q. Is there a Windows version of Python?
|
||||
|
||||
A. Not yet. Several Windows hackers with C compilers are working on a
|
||||
port though, so maybe we'll have one soon.
|
||||
|
||||
7.3. Q. I have the Mac or DOS version but it appears to be only a binary.
|
||||
Where's the library?
|
||||
|
||||
A. You still need to copy the files from the distribution directory
|
||||
"python/lib" to your system. If you don't have the full distribution,
|
||||
you can ftp the file pythonlib0.9.9.tar.Z from site ftp.cwi.nl,
|
||||
directory /pub/python; this is a subset of the distribution containing
|
||||
just those file.
|
||||
|
||||
7.4. Q. Where's the documentation for the Mac or DOS version?
|
||||
|
||||
A. There isn't any. The documentation for the Unix version also
|
||||
applies to the Mac and DOS versions. Where applicable, differences
|
||||
are indicated in the text.
|
||||
|
||||
7.5. Q. The Mac version doesn't seem to have any facilities for creating or
|
||||
editing programs apart from entering it interactively, and there seems
|
||||
to be no way to save code that was entered interactively. How do I
|
||||
create a Python program on the Mac?
|
||||
|
||||
A. Use an external editor. I am quite happy with the Desk Accessory
|
||||
called Sigma Edit; this doesn't require Multifinder or System 7. I
|
||||
work like this: start the interpreter; edit a module file using Sigma
|
||||
Edit; import and test it in the interpreter; edit again in Sigma Edit;
|
||||
then use the built-in function reload() to re-read the imported
|
||||
module; etc.
|
69
Misc/Fixcprt.py
Executable file
69
Misc/Fixcprt.py
Executable file
|
@ -0,0 +1,69 @@
|
|||
#! /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()
|
1400
Misc/HISTORY
Normal file
1400
Misc/HISTORY
Normal file
File diff suppressed because it is too large
Load diff
10
Misc/Makefile
Normal file
10
Misc/Makefile
Normal file
|
@ -0,0 +1,10 @@
|
|||
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
|
20
Misc/README
Normal file
20
Misc/README
Normal file
|
@ -0,0 +1,20 @@
|
|||
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
|
114
Misc/RFD
Normal file
114
Misc/RFD
Normal file
|
@ -0,0 +1,114 @@
|
|||
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.
|
47
Misc/fixfuncptrs.sh
Executable file
47
Misc/fixfuncptrs.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
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
|
1601
Misc/python-mode-old.el
Normal file
1601
Misc/python-mode-old.el
Normal file
File diff suppressed because it is too large
Load diff
BIN
Misc/python.gif
Normal file
BIN
Misc/python.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
247
Misc/python.man
Normal file
247
Misc/python.man
Normal file
|
@ -0,0 +1,247 @@
|
|||
.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.
|
108
Misc/renumber.py
Executable file
108
Misc/renumber.py
Executable file
|
@ -0,0 +1,108 @@
|
|||
#! /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()
|
Loading…
Add table
Add a link
Reference in a new issue