2007-08-15 14:28:22 +00:00
|
|
|
*************************
|
|
|
|
Python Advocacy HOWTO
|
|
|
|
*************************
|
|
|
|
|
|
|
|
:Author: A.M. Kuchling
|
|
|
|
:Release: 0.03
|
|
|
|
|
|
|
|
|
|
|
|
.. topic:: Abstract
|
|
|
|
|
|
|
|
It's usually difficult to get your management to accept open source software,
|
|
|
|
and Python is no exception to this rule. This document discusses reasons to use
|
|
|
|
Python, strategies for winning acceptance, facts and arguments you can use, and
|
|
|
|
cases where you *shouldn't* try to use Python.
|
|
|
|
|
|
|
|
|
|
|
|
Reasons to Use Python
|
|
|
|
=====================
|
|
|
|
|
|
|
|
There are several reasons to incorporate a scripting language into your
|
|
|
|
development process, and this section will discuss them, and why Python has some
|
|
|
|
properties that make it a particularly good choice.
|
|
|
|
|
|
|
|
|
|
|
|
Programmability
|
|
|
|
---------------
|
|
|
|
|
|
|
|
Programs are often organized in a modular fashion. Lower-level operations are
|
|
|
|
grouped together, and called by higher-level functions, which may in turn be
|
|
|
|
used as basic operations by still further upper levels.
|
|
|
|
|
|
|
|
For example, the lowest level might define a very low-level set of functions for
|
|
|
|
accessing a hash table. The next level might use hash tables to store the
|
|
|
|
headers of a mail message, mapping a header name like ``Date`` to a value such
|
|
|
|
as ``Tue, 13 May 1997 20:00:54 -0400``. A yet higher level may operate on
|
|
|
|
message objects, without knowing or caring that message headers are stored in a
|
|
|
|
hash table, and so forth.
|
|
|
|
|
|
|
|
Often, the lowest levels do very simple things; they implement a data structure
|
|
|
|
such as a binary tree or hash table, or they perform some simple computation,
|
|
|
|
such as converting a date string to a number. The higher levels then contain
|
|
|
|
logic connecting these primitive operations. Using the approach, the primitives
|
|
|
|
can be seen as basic building blocks which are then glued together to produce
|
|
|
|
the complete product.
|
|
|
|
|
|
|
|
Why is this design approach relevant to Python? Because Python is well suited
|
|
|
|
to functioning as such a glue language. A common approach is to write a Python
|
|
|
|
module that implements the lower level operations; for the sake of speed, the
|
|
|
|
implementation might be in C, Java, or even Fortran. Once the primitives are
|
|
|
|
available to Python programs, the logic underlying higher level operations is
|
|
|
|
written in the form of Python code. The high-level logic is then more
|
|
|
|
understandable, and easier to modify.
|
|
|
|
|
|
|
|
John Ousterhout wrote a paper that explains this idea at greater length,
|
|
|
|
entitled "Scripting: Higher Level Programming for the 21st Century". I
|
|
|
|
recommend that you read this paper; see the references for the URL. Ousterhout
|
|
|
|
is the inventor of the Tcl language, and therefore argues that Tcl should be
|
|
|
|
used for this purpose; he only briefly refers to other languages such as Python,
|
|
|
|
Perl, and Lisp/Scheme, but in reality, Ousterhout's argument applies to
|
|
|
|
scripting languages in general, since you could equally write extensions for any
|
|
|
|
of the languages mentioned above.
|
|
|
|
|
|
|
|
|
|
|
|
Prototyping
|
|
|
|
-----------
|
|
|
|
|
|
|
|
In *The Mythical Man-Month*, Fredrick Brooks suggests the following rule when
|
|
|
|
planning software projects: "Plan to throw one away; you will anyway." Brooks
|
|
|
|
is saying that the first attempt at a software design often turns out to be
|
|
|
|
wrong; unless the problem is very simple or you're an extremely good designer,
|
|
|
|
you'll find that new requirements and features become apparent once development
|
|
|
|
has actually started. If these new requirements can't be cleanly incorporated
|
|
|
|
into the program's structure, you're presented with two unpleasant choices:
|
|
|
|
hammer the new features into the program somehow, or scrap everything and write
|
|
|
|
a new version of the program, taking the new features into account from the
|
|
|
|
beginning.
|
|
|
|
|
|
|
|
Python provides you with a good environment for quickly developing an initial
|
|
|
|
prototype. That lets you get the overall program structure and logic right, and
|
|
|
|
you can fine-tune small details in the fast development cycle that Python
|
|
|
|
provides. Once you're satisfied with the GUI interface or program output, you
|
|
|
|
can translate the Python code into C++, Fortran, Java, or some other compiled
|
|
|
|
language.
|
|
|
|
|
|
|
|
Prototyping means you have to be careful not to use too many Python features
|
|
|
|
that are hard to implement in your other language. Using ``eval()``, or regular
|
|
|
|
expressions, or the :mod:`pickle` module, means that you're going to need C or
|
|
|
|
Java libraries for formula evaluation, regular expressions, and serialization,
|
|
|
|
for example. But it's not hard to avoid such tricky code, and in the end the
|
|
|
|
translation usually isn't very difficult. The resulting code can be rapidly
|
|
|
|
debugged, because any serious logical errors will have been removed from the
|
|
|
|
prototype, leaving only more minor slip-ups in the translation to track down.
|
|
|
|
|
|
|
|
This strategy builds on the earlier discussion of programmability. Using Python
|
|
|
|
as glue to connect lower-level components has obvious relevance for constructing
|
|
|
|
prototype systems. In this way Python can help you with development, even if
|
|
|
|
end users never come in contact with Python code at all. If the performance of
|
|
|
|
the Python version is adequate and corporate politics allow it, you may not need
|
|
|
|
to do a translation into C or Java, but it can still be faster to develop a
|
|
|
|
prototype and then translate it, instead of attempting to produce the final
|
|
|
|
version immediately.
|
|
|
|
|
|
|
|
One example of this development strategy is Microsoft Merchant Server. Version
|
|
|
|
1.0 was written in pure Python, by a company that subsequently was purchased by
|
|
|
|
Microsoft. Version 2.0 began to translate the code into C++, shipping with some
|
|
|
|
C++code and some Python code. Version 3.0 didn't contain any Python at all; all
|
|
|
|
the code had been translated into C++. Even though the product doesn't contain
|
|
|
|
a Python interpreter, the Python language has still served a useful purpose by
|
|
|
|
speeding up development.
|
|
|
|
|
|
|
|
This is a very common use for Python. Past conference papers have also
|
|
|
|
described this approach for developing high-level numerical algorithms; see
|
|
|
|
David M. Beazley and Peter S. Lomdahl's paper "Feeding a Large-scale Physics
|
|
|
|
Application to Python" in the references for a good example. If an algorithm's
|
|
|
|
basic operations are things like "Take the inverse of this 4000x4000 matrix",
|
|
|
|
and are implemented in some lower-level language, then Python has almost no
|
|
|
|
additional performance cost; the extra time required for Python to evaluate an
|
|
|
|
expression like ``m.invert()`` is dwarfed by the cost of the actual computation.
|
|
|
|
It's particularly good for applications where seemingly endless tweaking is
|
|
|
|
required to get things right. GUI interfaces and Web sites are prime examples.
|
|
|
|
|
|
|
|
The Python code is also shorter and faster to write (once you're familiar with
|
|
|
|
Python), so it's easier to throw it away if you decide your approach was wrong;
|
|
|
|
if you'd spent two weeks working on it instead of just two hours, you might
|
|
|
|
waste time trying to patch up what you've got out of a natural reluctance to
|
|
|
|
admit that those two weeks were wasted. Truthfully, those two weeks haven't
|
|
|
|
been wasted, since you've learnt something about the problem and the technology
|
|
|
|
you're using to solve it, but it's human nature to view this as a failure of
|
|
|
|
some sort.
|
|
|
|
|
|
|
|
|
|
|
|
Simplicity and Ease of Understanding
|
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
Python is definitely *not* a toy language that's only usable for small tasks.
|
|
|
|
The language features are general and powerful enough to enable it to be used
|
|
|
|
for many different purposes. It's useful at the small end, for 10- or 20-line
|
|
|
|
scripts, but it also scales up to larger systems that contain thousands of lines
|
|
|
|
of code.
|
|
|
|
|
|
|
|
However, this expressiveness doesn't come at the cost of an obscure or tricky
|
|
|
|
syntax. While Python has some dark corners that can lead to obscure code, there
|
|
|
|
are relatively few such corners, and proper design can isolate their use to only
|
|
|
|
a few classes or modules. It's certainly possible to write confusing code by
|
|
|
|
using too many features with too little concern for clarity, but most Python
|
|
|
|
code can look a lot like a slightly-formalized version of human-understandable
|
|
|
|
pseudocode.
|
|
|
|
|
|
|
|
In *The New Hacker's Dictionary*, Eric S. Raymond gives the following definition
|
|
|
|
for "compact":
|
|
|
|
|
|
|
|
.. epigraph::
|
|
|
|
|
|
|
|
Compact *adj.* Of a design, describes the valuable property that it can all be
|
|
|
|
apprehended at once in one's head. This generally means the thing created from
|
|
|
|
the design can be used with greater facility and fewer errors than an equivalent
|
|
|
|
tool that is not compact. Compactness does not imply triviality or lack of
|
|
|
|
power; for example, C is compact and FORTRAN is not, but C is more powerful than
|
|
|
|
FORTRAN. Designs become non-compact through accreting features and cruft that
|
|
|
|
don't merge cleanly into the overall design scheme (thus, some fans of Classic C
|
|
|
|
maintain that ANSI C is no longer compact).
|
|
|
|
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 13:31:39 +00:00
|
|
|
(From http://www.catb.org/~esr/jargon/html/C/compact.html)
|
2007-08-15 14:28:22 +00:00
|
|
|
|
|
|
|
In this sense of the word, Python is quite compact, because the language has
|
|
|
|
just a few ideas, which are used in lots of places. Take namespaces, for
|
|
|
|
example. Import a module with ``import math``, and you create a new namespace
|
|
|
|
called ``math``. Classes are also namespaces that share many of the properties
|
|
|
|
of modules, and have a few of their own; for example, you can create instances
|
|
|
|
of a class. Instances? They're yet another namespace. Namespaces are currently
|
|
|
|
implemented as Python dictionaries, so they have the same methods as the
|
|
|
|
standard dictionary data type: .keys() returns all the keys, and so forth.
|
|
|
|
|
|
|
|
This simplicity arises from Python's development history. The language syntax
|
|
|
|
derives from different sources; ABC, a relatively obscure teaching language, is
|
|
|
|
one primary influence, and Modula-3 is another. (For more information about ABC
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 13:31:39 +00:00
|
|
|
and Modula-3, consult their respective Web sites at http://www.cwi.nl/~steven/abc/
|
|
|
|
and http://www.m3.org.) Other features have come from C, Icon,
|
2007-08-15 14:28:22 +00:00
|
|
|
Algol-68, and even Perl. Python hasn't really innovated very much, but instead
|
|
|
|
has tried to keep the language small and easy to learn, building on ideas that
|
|
|
|
have been tried in other languages and found useful.
|
|
|
|
|
|
|
|
Simplicity is a virtue that should not be underestimated. It lets you learn the
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 13:31:39 +00:00
|
|
|
language more quickly, and then rapidly write code -- code that often works the
|
2007-08-15 14:28:22 +00:00
|
|
|
first time you run it.
|
|
|
|
|
|
|
|
|
|
|
|
Java Integration
|
|
|
|
----------------
|
|
|
|
|
|
|
|
If you're working with Java, Jython (http://www.jython.org/) is definitely worth
|
|
|
|
your attention. Jython is a re-implementation of Python in Java that compiles
|
|
|
|
Python code into Java bytecodes. The resulting environment has very tight,
|
|
|
|
almost seamless, integration with Java. It's trivial to access Java classes
|
|
|
|
from Python, and you can write Python classes that subclass Java classes.
|
|
|
|
Jython can be used for prototyping Java applications in much the same way
|
|
|
|
CPython is used, and it can also be used for test suites for Java code, or
|
|
|
|
embedded in a Java application to add scripting capabilities.
|
|
|
|
|
|
|
|
|
|
|
|
Arguments and Rebuttals
|
|
|
|
=======================
|
|
|
|
|
|
|
|
Let's say that you've decided upon Python as the best choice for your
|
|
|
|
application. How can you convince your management, or your fellow developers,
|
|
|
|
to use Python? This section lists some common arguments against using Python,
|
|
|
|
and provides some possible rebuttals.
|
|
|
|
|
|
|
|
**Python is freely available software that doesn't cost anything. How good can
|
|
|
|
it be?**
|
|
|
|
|
|
|
|
Very good, indeed. These days Linux and Apache, two other pieces of open source
|
|
|
|
software, are becoming more respected as alternatives to commercial software,
|
|
|
|
but Python hasn't had all the publicity.
|
|
|
|
|
|
|
|
Python has been around for several years, with many users and developers.
|
|
|
|
Accordingly, the interpreter has been used by many people, and has gotten most
|
|
|
|
of the bugs shaken out of it. While bugs are still discovered at intervals,
|
|
|
|
they're usually either quite obscure (they'd have to be, for no one to have run
|
|
|
|
into them before) or they involve interfaces to external libraries. The
|
|
|
|
internals of the language itself are quite stable.
|
|
|
|
|
|
|
|
Having the source code should be viewed as making the software available for
|
|
|
|
peer review; people can examine the code, suggest (and implement) improvements,
|
|
|
|
and track down bugs. To find out more about the idea of open source code, along
|
|
|
|
with arguments and case studies supporting it, go to http://www.opensource.org.
|
|
|
|
|
|
|
|
**Who's going to support it?**
|
|
|
|
|
|
|
|
Python has a sizable community of developers, and the number is still growing.
|
|
|
|
The Internet community surrounding the language is an active one, and is worth
|
|
|
|
being considered another one of Python's advantages. Most questions posted to
|
|
|
|
the comp.lang.python newsgroup are quickly answered by someone.
|
|
|
|
|
|
|
|
Should you need to dig into the source code, you'll find it's clear and
|
|
|
|
well-organized, so it's not very difficult to write extensions and track down
|
|
|
|
bugs yourself. If you'd prefer to pay for support, there are companies and
|
|
|
|
individuals who offer commercial support for Python.
|
|
|
|
|
|
|
|
**Who uses Python for serious work?**
|
|
|
|
|
|
|
|
Lots of people; one interesting thing about Python is the surprising diversity
|
|
|
|
of applications that it's been used for. People are using Python to:
|
|
|
|
|
|
|
|
* Run Web sites
|
|
|
|
|
|
|
|
* Write GUI interfaces
|
|
|
|
|
|
|
|
* Control number-crunching code on supercomputers
|
|
|
|
|
|
|
|
* Make a commercial application scriptable by embedding the Python interpreter
|
|
|
|
inside it
|
|
|
|
|
|
|
|
* Process large XML data sets
|
|
|
|
|
|
|
|
* Build test suites for C or Java code
|
|
|
|
|
|
|
|
Whatever your application domain is, there's probably someone who's used Python
|
|
|
|
for something similar. Yet, despite being useable for such high-end
|
|
|
|
applications, Python's still simple enough to use for little jobs.
|
|
|
|
|
|
|
|
See http://wiki.python.org/moin/OrganizationsUsingPython for a list of some of
|
|
|
|
the organizations that use Python.
|
|
|
|
|
|
|
|
**What are the restrictions on Python's use?**
|
|
|
|
|
|
|
|
They're practically nonexistent. Consult the :file:`Misc/COPYRIGHT` file in the
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
source distribution, or the section :ref:`history-and-license` for the full
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 13:31:39 +00:00
|
|
|
language, but it boils down to three conditions:
|
2007-08-15 14:28:22 +00:00
|
|
|
|
|
|
|
* You have to leave the copyright notice on the software; if you don't include
|
|
|
|
the source code in a product, you have to put the copyright notice in the
|
|
|
|
supporting documentation.
|
|
|
|
|
|
|
|
* Don't claim that the institutions that have developed Python endorse your
|
|
|
|
product in any way.
|
|
|
|
|
|
|
|
* If something goes wrong, you can't sue for damages. Practically all software
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60901 | eric.smith | 2008-02-19 14:21:56 +0100 (Tue, 19 Feb 2008) | 1 line
Added PEP 3101.
........
r60907 | georg.brandl | 2008-02-20 20:12:36 +0100 (Wed, 20 Feb 2008) | 2 lines
Fixes contributed by Ori Avtalion.
........
r60909 | eric.smith | 2008-02-21 00:34:22 +0100 (Thu, 21 Feb 2008) | 1 line
Trim leading zeros from a floating point exponent, per C99. See issue 1600. As far as I know, this only affects Windows. Add float type 'n' to PyOS_ascii_formatd (see PEP 3101 for 'n' description).
........
r60910 | eric.smith | 2008-02-21 00:39:28 +0100 (Thu, 21 Feb 2008) | 1 line
Now that PyOS_ascii_formatd supports the 'n' format, simplify the float formatting code to just call it.
........
r60918 | andrew.kuchling | 2008-02-21 15:23:38 +0100 (Thu, 21 Feb 2008) | 2 lines
Close manifest file.
This change doesn't make any difference to CPython, but is a necessary fix for Jython.
........
r60921 | guido.van.rossum | 2008-02-21 18:46:16 +0100 (Thu, 21 Feb 2008) | 2 lines
Remove news about float repr() -- issue 1580 is still in limbo.
........
r60923 | guido.van.rossum | 2008-02-21 19:18:37 +0100 (Thu, 21 Feb 2008) | 5 lines
Removed uses of dict.has_key() from distutils, and uses of
callable() from copy_reg.py, so the interpreter now starts up
without warnings when '-3' is given. More work like this needs to
be done in the rest of the stdlib.
........
r60924 | thomas.heller | 2008-02-21 19:28:48 +0100 (Thu, 21 Feb 2008) | 4 lines
configure.ac: Remove the configure check for _Bool, it is already done in the
top-level Python configure script.
configure, fficonfig.h.in: regenerated.
........
r60925 | thomas.heller | 2008-02-21 19:52:20 +0100 (Thu, 21 Feb 2008) | 3 lines
Replace 'has_key()' with 'in'.
Replace 'raise Error, stuff' with 'raise Error(stuff)'.
........
r60927 | raymond.hettinger | 2008-02-21 20:24:53 +0100 (Thu, 21 Feb 2008) | 1 line
Update more instances of has_key().
........
r60928 | guido.van.rossum | 2008-02-21 20:46:35 +0100 (Thu, 21 Feb 2008) | 3 lines
Fix a few typos and layout glitches (more work is needed).
Move 2.5 news to Misc/HISTORY.
........
r60936 | georg.brandl | 2008-02-21 21:33:38 +0100 (Thu, 21 Feb 2008) | 2 lines
#2079: typo in userdict docs.
........
r60938 | georg.brandl | 2008-02-21 21:38:13 +0100 (Thu, 21 Feb 2008) | 2 lines
Part of #2154: minimal syntax fixes in doc example snippets.
........
r60942 | raymond.hettinger | 2008-02-22 04:16:42 +0100 (Fri, 22 Feb 2008) | 1 line
First draft for itertools.product(). Docs and other updates forthcoming.
........
r60955 | nick.coghlan | 2008-02-22 11:54:06 +0100 (Fri, 22 Feb 2008) | 1 line
Try to make command line error messages from runpy easier to understand (and suppress traceback cruft from the implicitly invoked runpy machinery)
........
r60956 | georg.brandl | 2008-02-22 13:31:45 +0100 (Fri, 22 Feb 2008) | 2 lines
A lot more typo fixes by Ori Avtalion.
........
r60957 | georg.brandl | 2008-02-22 13:56:34 +0100 (Fri, 22 Feb 2008) | 2 lines
Don't reference pyshell.
........
r60958 | georg.brandl | 2008-02-22 13:57:05 +0100 (Fri, 22 Feb 2008) | 2 lines
Another fix.
........
2008-02-22 16:37:40 +00:00
|
|
|
licenses contain this condition.
|
2007-08-15 14:28:22 +00:00
|
|
|
|
|
|
|
Notice that you don't have to provide source code for anything that contains
|
|
|
|
Python or is built with it. Also, the Python interpreter and accompanying
|
|
|
|
documentation can be modified and redistributed in any way you like, and you
|
|
|
|
don't have to pay anyone any licensing fees at all.
|
|
|
|
|
|
|
|
**Why should we use an obscure language like Python instead of well-known
|
|
|
|
language X?**
|
|
|
|
|
|
|
|
I hope this HOWTO, and the documents listed in the final section, will help
|
|
|
|
convince you that Python isn't obscure, and has a healthily growing user base.
|
|
|
|
One word of advice: always present Python's positive advantages, instead of
|
|
|
|
concentrating on language X's failings. People want to know why a solution is
|
|
|
|
good, rather than why all the other solutions are bad. So instead of attacking
|
|
|
|
a competing solution on various grounds, simply show how Python's virtues can
|
|
|
|
help.
|
|
|
|
|
|
|
|
|
|
|
|
Useful Resources
|
|
|
|
================
|
|
|
|
|
|
|
|
http://www.pythonology.com/success
|
|
|
|
The Python Success Stories are a collection of stories from successful users of
|
|
|
|
Python, with the emphasis on business and corporate users.
|
|
|
|
|
Merged revisions 59605-59624 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59606 | georg.brandl | 2007-12-29 11:57:00 +0100 (Sat, 29 Dec 2007) | 2 lines
Some cleanup in the docs.
........
r59611 | martin.v.loewis | 2007-12-29 19:49:21 +0100 (Sat, 29 Dec 2007) | 2 lines
Bug #1699: Define _BSD_SOURCE only on OpenBSD.
........
r59612 | raymond.hettinger | 2007-12-29 23:09:34 +0100 (Sat, 29 Dec 2007) | 1 line
Simpler documentation for itertools.tee(). Should be backported.
........
r59613 | raymond.hettinger | 2007-12-29 23:16:24 +0100 (Sat, 29 Dec 2007) | 1 line
Improve docs for itertools.groupby(). The use of xrange(0) to create a unique object is less obvious than object().
........
r59620 | christian.heimes | 2007-12-31 15:47:07 +0100 (Mon, 31 Dec 2007) | 3 lines
Added wininst-9.0.exe executable for VS 2008
Integrated bdist_wininst into PCBuild9 directory
........
r59621 | christian.heimes | 2007-12-31 15:51:18 +0100 (Mon, 31 Dec 2007) | 1 line
Moved PCbuild directory to PC/VS7.1
........
r59622 | christian.heimes | 2007-12-31 15:59:26 +0100 (Mon, 31 Dec 2007) | 1 line
Fix paths for build bot
........
r59623 | christian.heimes | 2007-12-31 16:02:41 +0100 (Mon, 31 Dec 2007) | 1 line
Fix paths for build bot, part 2
........
r59624 | christian.heimes | 2007-12-31 16:18:55 +0100 (Mon, 31 Dec 2007) | 1 line
Renamed PCBuild9 directory to PCBuild
........
2007-12-31 16:14:33 +00:00
|
|
|
.. http://www.fsbassociates.com/books/pythonchpt1.htm
|
|
|
|
The first chapter of \emph{Internet Programming with Python} also
|
|
|
|
examines some of the reasons for using Python. The book is well worth
|
|
|
|
buying, but the publishers have made the first chapter available on
|
|
|
|
the Web.
|
2007-08-15 14:28:22 +00:00
|
|
|
|
|
|
|
http://home.pacbell.net/ouster/scripting.html
|
|
|
|
John Ousterhout's white paper on scripting is a good argument for the utility of
|
|
|
|
scripting languages, though naturally enough, he emphasizes Tcl, the language he
|
|
|
|
developed. Most of the arguments would apply to any scripting language.
|
|
|
|
|
|
|
|
http://www.python.org/workshops/1997-10/proceedings/beazley.html
|
|
|
|
The authors, David M. Beazley and Peter S. Lomdahl, describe their use of
|
|
|
|
Python at Los Alamos National Laboratory. It's another good example of how
|
|
|
|
Python can help get real work done. This quotation from the paper has been
|
|
|
|
echoed by many people:
|
|
|
|
|
|
|
|
.. epigraph::
|
|
|
|
|
|
|
|
Originally developed as a large monolithic application for massively parallel
|
|
|
|
processing systems, we have used Python to transform our application into a
|
|
|
|
flexible, highly modular, and extremely powerful system for performing
|
|
|
|
simulation, data analysis, and visualization. In addition, we describe how
|
|
|
|
Python has solved a number of important problems related to the development,
|
|
|
|
debugging, deployment, and maintenance of scientific software.
|
|
|
|
|
|
|
|
http://pythonjournal.cognizor.com/pyj1/Everitt-Feit_interview98-V1.html
|
|
|
|
This interview with Andy Feit, discussing Infoseek's use of Python, can be used
|
|
|
|
to show that choosing Python didn't introduce any difficulties into a company's
|
|
|
|
development process, and provided some substantial benefits.
|
|
|
|
|
Merged revisions 59605-59624 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59606 | georg.brandl | 2007-12-29 11:57:00 +0100 (Sat, 29 Dec 2007) | 2 lines
Some cleanup in the docs.
........
r59611 | martin.v.loewis | 2007-12-29 19:49:21 +0100 (Sat, 29 Dec 2007) | 2 lines
Bug #1699: Define _BSD_SOURCE only on OpenBSD.
........
r59612 | raymond.hettinger | 2007-12-29 23:09:34 +0100 (Sat, 29 Dec 2007) | 1 line
Simpler documentation for itertools.tee(). Should be backported.
........
r59613 | raymond.hettinger | 2007-12-29 23:16:24 +0100 (Sat, 29 Dec 2007) | 1 line
Improve docs for itertools.groupby(). The use of xrange(0) to create a unique object is less obvious than object().
........
r59620 | christian.heimes | 2007-12-31 15:47:07 +0100 (Mon, 31 Dec 2007) | 3 lines
Added wininst-9.0.exe executable for VS 2008
Integrated bdist_wininst into PCBuild9 directory
........
r59621 | christian.heimes | 2007-12-31 15:51:18 +0100 (Mon, 31 Dec 2007) | 1 line
Moved PCbuild directory to PC/VS7.1
........
r59622 | christian.heimes | 2007-12-31 15:59:26 +0100 (Mon, 31 Dec 2007) | 1 line
Fix paths for build bot
........
r59623 | christian.heimes | 2007-12-31 16:02:41 +0100 (Mon, 31 Dec 2007) | 1 line
Fix paths for build bot, part 2
........
r59624 | christian.heimes | 2007-12-31 16:18:55 +0100 (Mon, 31 Dec 2007) | 1 line
Renamed PCBuild9 directory to PCBuild
........
2007-12-31 16:14:33 +00:00
|
|
|
.. http://www.python.org/psa/Commercial.html
|
|
|
|
Robin Friedrich wrote this document on how to support Python's use in
|
|
|
|
commercial projects.
|
2007-08-15 14:28:22 +00:00
|
|
|
|
|
|
|
http://www.python.org/workshops/1997-10/proceedings/stein.ps
|
|
|
|
For the 6th Python conference, Greg Stein presented a paper that traced Python's
|
|
|
|
adoption and usage at a startup called eShop, and later at Microsoft.
|
|
|
|
|
|
|
|
http://www.opensource.org
|
|
|
|
Management may be doubtful of the reliability and usefulness of software that
|
|
|
|
wasn't written commercially. This site presents arguments that show how open
|
|
|
|
source software can have considerable advantages over closed-source software.
|
|
|
|
|
|
|
|
http://sunsite.unc.edu/LDP/HOWTO/mini/Advocacy.html
|
|
|
|
The Linux Advocacy mini-HOWTO was the inspiration for this document, and is also
|
|
|
|
well worth reading for general suggestions on winning acceptance for a new
|
|
|
|
technology, such as Linux or Python. In general, you won't make much progress
|
|
|
|
by simply attacking existing systems and complaining about their inadequacies;
|
|
|
|
this often ends up looking like unfocused whining. It's much better to point
|
|
|
|
out some of the many areas where Python is an improvement over other systems.
|
|
|
|
|