Programming Python with CDROM

Programming Python with CDROM

by Mark Lutz
     
 

Programming Python is a classic O'Reilly Nutshell Handbook® describing the use of the Python programming/scripting language. Python is a popular scripting language freely available over the Net. Like Perl, Python is powerful, but easier to use than a traditional compiler language like C or C++. Although it is used mostly in UNIX environments (including

…  See more details below

Overview

Programming Python is a classic O'Reilly Nutshell Handbook® describing the use of the Python programming/scripting language. Python is a popular scripting language freely available over the Net. Like Perl, Python is powerful, but easier to use than a traditional compiler language like C or C++. Although it is used mostly in UNIX environments (including Linux), it is available on Windows and Mac platforms as well. Unlike Perl, Python uses an object-oriented paradigm, making it a particularly useful scripting language for C++ programmers and the Windows/OLE and Mac environments. This book will serve the Python community as our Programming Perl book does for the Perl community.This book complements the online reference material provided with the Python releases. It is endorsed by the creator of Python, Guido van Rossum, who wrote the foreword. The CD-ROM included with the book contains Python 1.3 binaries for most popular UNIX platforms, as well as Linux, Windows, NT, and the Mac. This book is the most comprehensive Python user material available from any publisher. It contains a number of running examples, presented simply at first but becoming more complex as new issues appear. Examples describing Graphical User Interface (GUI) programming use the Tk language. (Tk is usually considered a part of the Tcl scripting language, but is in fact usable with other scripting languages like Perl and Python.)An appendix contains a separate short language tutorial.

Read More

Product Details

ISBN-13:
9781565921979
Publisher:
O'Reilly Media, Incorporated
Publication date:
10/08/1996
Series:
Nutshell Handbooks Series
Edition description:
BK&CD-ROM
Pages:
902
Product dimensions:
7.05(w) x 9.39(h) x 1.78(d)

Read an Excerpt


Chapter 1: So What's Python?

"And Now for Something Completely Different.."

This book is about using Python, a public-domain programming language. In acronyms, Python is both a very-high-level language (VHLL), and an object-oriented dynamic language (OODL). As a preliminary definition, Python can be described as a new kind of language tool. For many users, its

  • Support for object-oriented development

  • Powerful programming constructs

  • Extendible and embeddable architecture

  • Remarkably clear syntax and coherent design

make it almost ideal as both a scripting interface for modern systems, and a stand-alone rapid- development language. For example, Python's object-oriented nature mixes well with frameworks written in C++. And as a standalone tool, Python is commonly used in domains such as system administration, graphical user interfaces, internet scripting, and database programming. We'll refine this description in a moment.

The Life of Python

Python was invented around 1990 by Guido van Rossum, at CWI in Amsterdam. Despite the reptiles, it's named after the BBC comedy series Monty Python's Flying Circus. Guido was also involved with the Amoeba distributed operating system and the ABC language. in fact, the original motivation for Python was to create an advanced scripting language for the Amoeba system.

But Python's design turned out to be general enough for a wide variety of domains. It's now used by a growing number of engineers around the world, in increasingly diverse roles. For instance, a number of companies use Python in commercial products, for tasks such as GUI development tools, WWW scripting, interactive television, rapid program development, on-site customization of C++ class libraries, and more.

Since it first appeared on the public, domain scene in 1991, Python has continued to attract a loyal following, and spawned a dedicated Internet newsgroup, comp.lang.python, in 1994. And as this book was being written, Python's homepage debuted on the WWW at http://www.python.org/.

To help manage Python's growth, an informal organization aimed at supporting Python developers has begun taking shape: the Python Software Activity, or PSA for short. Despite its public domain status, Python is a well-supported system, thanks to the dedication of its inventor and the Python community. For example, the PSA facilitates Python workshops, and maintains a software and resources locator service.


"Buses considered harmful"

The PSA was originally formed in response to a thread on the Python newsgroup, which posed the semiserious question: "What would happen if Guido was hit by a bus?" Guido van Rossum still manages most new developments in Python, but the PSA and Python's user-base help support the language, work on extensions, etc. Given Python's popularity, and the PSA infrastructure, bus attacks seem less threatening now; of course I can't speak for Guido ...

Finally, Python is true freeware: there are no restrictions on copying it, or distributing it with your products. it comes with complete source code, a debugger and profiler, built-in interfaces to common external services, plus tools for adding other interfaces. System functions, GUls, and databases are supported "out of the box." Python programs run on most platforms, including nearly all flavors of UNIX, PCs (DOS, Windows, OS/2), the Macintosh, and others. And by the time you read this, Python should be part of most Linux distributions.

What's All the Excitement About?

Back to our description. Python has been called a "next-generation scripting language." This definition probably summarizes the language's distinctions, and the theme of this book, better than most. Although different people like different things about Python, there are some common reasons underlying its popularity. Some of the central points in the "Python philosophy" are:

Coherence

    A scripting language doesn't have to be hard to read, write, and maintain. Issues of aesthetics and readability need not be sacrificed in the interest of utility. With the right tool, there's no reason to abandon normal standards of quality, even for "quick and dirty" code.

Power

    An extension language doesn't have to have limited functionality. The design goals of embeddability and semantic power aren't necessarily contradictory: an extension tool can also be a full-featured programming language
.

Scope

    A dynamic language can be used for more than trivial tasks. There's no reason that a language can't both provide rapid response during the development cycle and also have features that make it useful for building more advanced systems.

Objects

    Object-oriented programming can be a useful paradigm, given the right tool. When easy to apply, OOP can be a powerful tool for structuring and reusing code. An object- oriented language doesn't necessarily also have to be complex or difficult to use.

Integration

    No language is an island. By providing both a powerful dynamic language, and well- defined interfaces to other languages, Python fosters hybrid systems that simultaneously leverage the rapid turnaround of Python, and the efficiency of C.

Python's integration support is a crucial property: as we'll see, much of Python's power comes from its open design, and its interfaces to external services. In fact, some consider Python's library of existing interfaces to be among its greatest assets. As we'll see, embedding APIs in a high-level language like Python makes them easier to use. Moreover, Python's integration tools make it practical to embed Python in products, and to apply paradigms such as rapid prototyping and rapid development.

But compared to other public-domain scripting languages, the first two points here- coherence and semantic power-may be Python's biggest distinctions. Aesthetic issues such as readability and design coherence are always hard to define, but crucial in a programming tool. As one Python user put it,

"Python looks like it was designed, not accumulated."
Python's inventor has done a extraordinary job of balancing the goals of simplicity and utility. We'll see that Python's clear syntax and high-level tools encourage the creation of easy-to-read, reusable software.

We'll also find that Python programs tend to resemble traditional languages such as C and Pascal, rather than scripting languages like Perl or Tcl. In fact, Python is something of a scripting language in the guise of a traditional language. Another observer summarized this fusion of ideas well:

"Python bridges the gap between scripting languages and C."
By providing a full-featured programming language and supporting modern development paradigms, Python brings programming tools used for more substantial systems to the scripting world. For example, C is poor for fast prototyping, and awk is almost useless for designing large systems, but Python does both well. In short, Python is a simple but powerful language, suitable both for "quick and dirty" scripts and medium-to-large-scale systems development.


Is it a "scripting language" or an "extension language"?

The terms "scripting language" and "extension language" are often used interchangeably to refer to an embedded, interpreted language component. Unfortunately, "scripting language" sometimes denotes system administration languages, used for writing shell tools. Since Python can be used in both roles, we'll use both terms too. But the term "scripting" isn't meant to imply that Python is just a shell tools language. For instance, we'll see that embedded Python code can take many forms: character strings, objects in module files, executable script files, and more.

...

Read More

Meet the Author

Mark Lutz is a leading Python trainer, the author of Python’s earliest and best-selling texts, and a pioneering figure in the Python world.

Mark is the author of the three O’Reilly books: Learning Python, Programming Python, and Python Pocket Reference, all currently in fourth or fifth editions. He has been using and promoting Python since 1992, started writing Python books in 1995, and began teaching Python classes in 1997. As of Spring 2013, Mark has instructed 260 Python training sessions, taught roughly 4,000 students in live classes, and written Python books that have sold 400,000 units and been translated to at least a dozen languages.

Together, his two decades of Python efforts have helped to establish it as one of the most widely used programming languages in the world today. In addition, Mark has been in the software field for 30 years. He holds BS and MS degrees in computer science from the University of Wisconsin where he explored implementations of the Prolog language, and over his career has worked as a professional software developer on compilers, programming tools, scripting applications, and assorted client/server systems.

Mark maintains a training website (http://learning-python.com) and an additional book support site on the Web (http://www.rmi.net/~lutz).

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >