Buy New

or
Sign in to turn on 1-Click ordering.
or
Amazon Prime Free Trial required. Sign up when you check out. Learn More
Buy Used
Used - Like New See details
$5.50 & eligible for FREE Super Saver Shipping on orders over $25. Details

or
Sign in to turn on 1-Click ordering.
 
   
More Buying Choices
Have one to sell? Sell yours here
Python: Create - Modify - Reuse
 
 
Tell the Publisher!
I'd like to read this book on Kindle

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

Python: Create - Modify - Reuse [Paperback]

James O. Knowlton (Author)
2.8 out of 5 stars  See all reviews (5 customer reviews)

List Price: $39.99
Price: $21.93 & eligible for FREE Super Saver Shipping on orders over $25. Details
You Save: $18.06 (45%)
  Special Offers Available
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
In Stock.
Ships from and sold by Amazon.com. Gift-wrap available.
Only 1 left in stock--order soon (more on the way).
Want it delivered Tuesday, January 31? Choose One-Day Shipping at checkout. Details
Textbook Student FREE Two-Day Shipping for Students. Learn more


Book Description

0470259329 978-0470259320 July 8, 2008 1
Python: Create-Modify-Reuse is designed for all levels of Python developers interested in a practical, hands-on way of learning Python development. This book is designed to show you how to use Python (in combination with the raw processing power of your computer) to accomplish real-world tasks in a more efficient way. Don't look for an exhaustive description of the Python language––you won't find it. The book's main purpose is not to thoroughly cover the Python language, but rather to show how you can use Python to create robust, real-world applications.

In this respect, the goal is similar to foreign-language books that identify themselves as “conversational,” focusing on the vocabulary and concepts that people will need the most. Likewise, I focus specifically on the Python knowledge needed to accomplish practical, specific tasks. Along the way, you will learn to create useful, efficient scripts that are easy to maintain and enhance.

This book is for developers with some experience with Python who want to explore how to develop full-blown applications. It is also for developers with experience in other languages who want to learn Python by building robust applications. It is well-suited for developers who like to “learn by doing,” rather than exploring a language feature by feature. To get the most out of the book, you should understand basic programming principles.

Because this book is project-based, you can approach it in numerous ways. You can, of course, read it from cover to cover. Chapters 2 through 8 each cover a different project, so the chapters are independent of each other. However, because each chapter project is covered individually, there may be some overlap of information. I also sometimes refer to explanations of particular topics covered in previous chapters. This will help to reinforce important concepts.

The end of the book contains two appendixes. The first one is a listing of Python resources you can check out for more information. The second one will help you with installing additional components used in some of the examples.

This book starts with a basic overview of the Python language, designed for those familiar with other languages but new to Python. It is followed by several chapters, each of which describes a complete project that can be used as-is or modified and extended to suit your particular purposes. You'll find applications that access databases, take advantage of web technologies, and facilitate network communications, to name a few. In addition, and more important than the technologies you will be introduced to, you will learn how to use Python to solve real challenges. Following these chapters are two chapters that cover accessing operating system resources and debugging and testing, respectively.

Each project chapter contains complete instructions describing how to install and use the application, so you can actually see the program run as you learn how to construct and use it, including how the project was designed and prototyped. This book is intended to be both a reference guide and a learning aid, teaching you how to build solutions with Python and providing reference information on a wide variety of Python programming concepts.

It is hoped that this book will help you have fun with Python and build useful applications, and—unlike my experience with building a deck—without sore thumbs.

This book is framed around the code itself. This is because developers are typically looking for how to do something; and, as with many activities, you learn how to do something by watching how others do and trying it yourself. If you want to know how a for loop works, you'll find for loops in my code, but that's not the thrust of the book. Instead, this book shows you how to do things: how to build a content management system, how to build a test management system, how to set up a system for tracking customer follow-up, and so on. Along the way, you'll learn how to communicate with a SQL database, how to act as a web server or communicate with one, how to access operating system services, and more.

There are three basic components to the book:

  • Chapter 1 is a brief overview of the Python language.

  • Chapters 2–8 cover seven different programming projects, which illustrate various technologies and techniques available to Python developers.

  • Chapters 9–10 cover additional, advanced topics, which will help you as you build Python projects.

The project chapters have a consistent structure:

  • Overview: What does the application do?

  • Using the program

  • Design

  • How it all fits together

  • Modules involved

  • Code and code explanation

  • Module/class 1 explanation

  • Module/class 2 explanation

  • Minor code file explanation

  • Testing, including suggested tests

  • Modifying the project, including some suggested adaptations

  • Summary

Each project is designed with classes that can be reused and accessed for multiple purposes. This is one of the main benefits of object-oriented programming, so designing for reusability is a main focus of the book. The book contains the following chapters:

1. Python Basics

This chapter is a basic primer on the Python language, and it functions as either a quick tutorial for experienced programmers new to Python or a refresher for programmers with Python experience.

Part I: The Projects

2. Directory/File Snapshot Program

This project demonstrates how to interact with files, create and manipulate data structures, and provide user output. It also touches on code design issues to improve code maintainability. Often when installing or uninstalling software, or verifying changes to a file system, it can be valuable to take a “snapshot” of the files and directories, along with their size and last-modified time. The script introduced in this chapter does just that. This chapter also explores how to capture a directory listing into a Python list, and explains how to query this list for particular values.

3. DVD Inventory System

This project takes advantage of Python’s capability to access and manipulate data in a SQL database. The application enables multiple users to log in to a website that provides access to a DVD inventory database. Permissions are set such that some users can add, modify, or delete entries, whereas other users have read-only access to the data.

4. Web Performance Tester

This project shows how to communicate with a Python web server and retrieve information regarding how long it takes to receive requested items from the web server. Although writing Python programs to work on a single computer can be useful, the real power of Python can be seen when it is used to script communication between computers on a network. Most networks contain several web servers. A nice feature of Python is that it can act as a lightweight server for various Internet protocols, such as HTTP (web) and ftp. This application enables you to monitor performance of HTTP traffic on your network.

5. Customer Follow-Up System

This project shows how to present a web form to the user and retrieve data from it, how to automatically format and send e-mail through an SMTP server, and how to generate an HTML-formatted report. The task for the second example is to automatically generate a customer comments e-mail message based on information the customer enters in a form. It uses the mod_python Apache module to take the information entered in the HTTP form and then utilizes a Python script on the web server to send that information to an SMTP server for mail delivery.

6. Test Management/Reporting System

This project makes use of the unittest module to run tests against an existing application, and creates a framework for reporting test results. Testing is a vital process for developing software. This application enables users to run tests for a given piece of software, to list the previous test runs by date, to show test run results for any previously run tests, and to output the results of any test run as HTML for viewing in a web browser.

7. Version Management System

This project connects to a list of servers via telnet, checks the application version of a pre-set application list, and displays its results both as output and to a log file. Often, a system administrator needs to patch systems or ensure that systems have the latest application versions installed. This script is an easy way to accomplish that task. It makes use of Python’s capability to emulate a telnet client and log in to remote systems and perform functions on that remote system.

8. Content Management System

This project explores Plone, a popular content management system based on Python and Zope (a Python-based application server). Because Python is a very mature language, numerous applications have been built on top of it. A great thing about working with Python-based applications is that you get the benefit of a full-blown application but you can still use Python to configure and customize it.

Part II: Advanced Topics

9. Interacting with the Operating System

When writing scripts “in the real world,” often it is critical to be able to access services available through (and particular to) the operating system you happen to be on. For example, suppose you wanted to read or modify the Window Registry? Or you wanted to get the Linux process ID of a particular process that is running? Is such a thing even possible? Definitely—and this chapter shows you how.

10. Debugging and Testing

Because I am a software tester myself, testing is a subject that is certainly close to my heart. In this chapter, I discuss why testing is important, how to put the right amount of testing into your code, and how writing automated tests can help you to actually write code more quickly. You’ll look at PyUnit, the automated testing framework for Python, and learn how to use it to test the riskiest parts of a script. You’ll also explore the Python de...


Special Offers and Product Promotions

  • Buy $50 in qualifying physical textbooks, get $5 in Amazon MP3 Credit. Here's how (restrictions apply)

Frequently Bought Together

Python: Create - Modify - Reuse + Beginning Python (Programmer to Programmer) + Professional Python Frameworks: Web 2.0 Programming with Django and Turbogears (Programmer to Programmer)
Price For All Three: $85.01

Some of these items ship sooner than the others. Show details

Buy the selected items together
  • In Stock.
    Ships from and sold by Amazon.com.
    Eligible for FREE Super Saver Shipping on orders over $25. Details

  • Beginning Python (Programmer to Programmer) $23.09

    Usually ships within 1 to 3 weeks.
    Ships from and sold by Amazon.com.
    Eligible for FREE Super Saver Shipping on orders over $25. Details

  • Professional Python Frameworks: Web 2.0 Programming with Django and Turbogears (Programmer to Programmer) $39.99

    In Stock.
    Ships from and sold by Amazon.com.
    This item ships for FREE with Super Saver Shipping. Details



Editorial Reviews

From the Back Cover

Python: Create-Modify-Reuse

Aimed at all levels of Python developers who are interested in a task-based way of learning Python development, this hands-on book shows how you can efficiently use Python to create robust, real-world applications. After a brief primer on this object-oriented, interactive programming language, you will jump right into practical Python development so that you can create useful, streamlined scripts that are easy to maintain and enhance, and that you can immediately put to use in the real world.

Each chapter features a complete project that you can use as it currently exists or modify to suit your particular purposes. Among these projects you'll find applications that access databases, take advantage of web technologies, facilitate network communications, and more. Plus, you'll also explore more advanced topics such as accessing operating system resources, writing scripts that are easy to read and maintain, and debugging and testing. However, even more important than the technologies you will be introduced to, you will learn how to use Python to solve real challenges.

What you will learn from this book

  • The various technologies and techniques that are available to Python developers

  • Ways to communicate with an SQL database

  • Tips for acting as a web server or communicating with one

  • How to access and manipulate XML files

  • Techniques for building a content management system

  • Ways to access and communicate with your operating system

Who this book is for
This book is for developers who want to explore how to develop full-blown applications with Python. A general understanding of basic programming principles and object-oriented design is helpful.

Create – Modify – Reuse guides are packed with unique, ready-to-use projects that are perfect for the busy programmer. The projects are created with minimal set-up, and can be modified, enhanced, and reused in real-world situations.

About the Author

Jim Knowlton is a software quality engineer with Automatic Data Processing (ADP), Inc., where he leads quality assurance efforts on ADP ’ s computer telephony integration and network video projects. He has been instrumental in introducing automated testing methodologies to their QA effort. He has more than fifteen years of experience in the software industry, including clients such as Symantec, Novell, Nike, and Zions Bank. He has extensive experience in open - source technologies, including Python, Ruby, PHP, Apache, and MySQL, and has also worked extensively in the areas of systems management and enterprise security. Jim holds a bachelor of arts degree in management and is currently working on a master of software engineering degree at Portland State University.

Product Details

  • Paperback: 262 pages
  • Publisher: Wrox; 1 edition (July 8, 2008)
  • Language: English
  • ISBN-10: 0470259329
  • ISBN-13: 978-0470259320
  • Product Dimensions: 7.4 x 0.6 x 9.3 inches
  • Shipping Weight: 12.8 ounces (View shipping rates and policies)
  • Average Customer Review: 2.8 out of 5 stars  See all reviews (5 customer reviews)
  • Amazon Best Sellers Rank: #1,533,536 in Books (See Top 100 in Books)

More About the Author

Discover books, learn about writers, read author blogs, and more.

 

Customer Reviews

5 Reviews
5 star:
 (1)
4 star:
 (1)
3 star:
 (1)
2 star:    (0)
1 star:
 (2)
 
 
 
 
 
Average Customer Review
2.8 out of 5 stars (5 customer reviews)
 
 
 
 
Share your thoughts with other customers:
Most Helpful Customer Reviews

3 of 3 people found the following review helpful:
1.0 out of 5 stars Wanted to like this book but just couldn't, January 16, 2010
By 
Aaron Dutton (Bellingham, WA USA) - See all my reviews
(REAL NAME)   
This review is from: Python: Create - Modify - Reuse (Paperback)
I really wanted to like this book. As a professional C# developer, I have been learning Python the last few weeks. I got this book in hopes that it would provide some interesting projects.

I could not bring myself to like this book. It was a painful read because this book demonstrates poor and obsolete programming practices. I feel like this book would probably set a beginner back instead of helping them move forward. I would recommend almost any other Python book over this one.

The book does have seven fairly interesting projects, covering a wide breadth of the Python standard library (xml parsing, database access, file input/output, etc) and some web-based projects. That is why I wanted to like it. It covers interesting topics. However, this is not enough to make up for the sloppy editing, obsolete user interfaces, and poor programming practices. I will detail some of the problems below.

Sloppy editing - For example, look at the code sample at the top of page 31. This wouldn't even "compile" in Python's editor IDLE, because of the incorrect indenting.

....elif choice == "4":
........snapshothelper.showHelp()
.........else:
........if choice != "5":
............snapshothelper.invalidChoice()

The "else:" is intended wrong and then on page 32 the same code is excerpted except it has been copied incorrectly:
....elif choice == "4":
........snapshothelper.showHelp()
....else:
.........snapshothelper.invalidChoice()

You can see that the author corrected a mistake in the main block of code but then did not correct it in the excerpt.

This is just the tip of the iceberg for code blocks that will cause errors upon running them inside Python.

On to the next problem - The user interface for the command-line projects looks like something out of MS-DOS 3.1. In other words, it is extremely outdated, cumbersome and it's not even programmed effectively. The error messages are obtuse and don't even cover all the cases. Frankly, I expect a lot more from an author with an extensive background in testing. For example, in page 70, the "elif" block never checks for choices that are not 1 through 5. If you have an invalid choice it will cause a SQL error and print the error message "THERE WAS A PROBLEM MODIFYING THE RECORD" even though the error was caused by an invalid choice.

My final complaint is that the author does not follow Pythonic practices or even best practices from other languages. For example, the Try-Except blocks (page 79 for example) include large swaths of code instead of just the small section that will actually throw the exception. Also, the Except clause does not catch particular error classes but instead every error. These violate basic best practices for any language. Another example of not being very Pythonic is the lack of list comprehensions like on page 37 (also note that this sample includes inconsistent indentation and would likely cause the Python interpreter to fail):
....for item in filelist:
............if item.find(extension) != -1:
................snaplist.append(item)

This could easily be re-written in the Pythonic way:
....snaplist = [for item in filelist if item.find(extension) = -1]

Unfortunately, I could go on and on talking about things I don't like about this book. The bottom line is that I don't recommend it.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


6 of 8 people found the following review helpful:
1.0 out of 5 stars Mediocre book and poor accompanying source, September 21, 2008
This review is from: Python: Create - Modify - Reuse (Paperback)
I was very disappointed by this book. I have come to expect more from WROX than this. If I was given this book without a cover, I would never have guessed the title. The book is organized more like a cookbook of projects that each illustrate a particular point or technique than a book titled "Create - Modify - Reuse".

The source code in the book is broken into fragments and isn't usable by itself. You will need to download the accompanying source from the publisher to run the programs. Unfortunately too much of the downloaded source is broken and has to be fixed before it will run. The style and organization of the code reminds me of a first year student's programming assignment.

I'm just glad I only borrowed this book from the library and it had to go back anyway.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


1 of 1 people found the following review helpful:
3.0 out of 5 stars Broad overviews, April 3, 2010
Amazon Verified Purchase(What's this?)
This review is from: Python: Create - Modify - Reuse (Paperback)
This is not a bad book, it just isn't a book for beginners. There is not a whole lot in the way of troubleshooting and if something that the book has you do does not work you more or less have to hack the code together yourself to get things off the ground. The community site that partners with this book and others in the series is a wasteland really. It doesn't seem to be active with many of the forum section completely barren and the forums sections with discussions have been inactive for several months if not years. In other words don't expect a whole lot of support from anywhere regarding what you read here. All in all though the book does have some interesting coding and can really help broaden intermediate coders perspectives on how to code in Python.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No

Share your thoughts with other customers: Create your own review
 
 
 
Most Recent Customer Reviews



Only search this product's reviews



Inside This Book (learn more)
Key Phrases - Statistically Improbable Phrases (SIPs): (learn more)
inventory system, site setup, version management system, elif choice, internal web server performance, test run file, minidom module, several ways this project, elif action, costar name, def menu, snapshot module, stack viewer, completed test run, snapshot files, snapshot program, compare snapshots, interactive interpreter, python version, snapshot list, base filename, insufficient arguments, show test results, most recent call, modified record
Key Phrases - Capitalized Phrases (CAPs): (learn more)
The Projects, Test Management, Function Return Type Description, File Snapshot Program, Program Files, Jim Knowlton, Pressing Enter, Reporting System, Cancel Figure, Mark Hammond, Advanced Topics, American Gangster, Modifying the Program There, Python Webserver, Python Shell, Web Performance Tester, Customer Follow-Up System, Denzel Washington, Home Users Welcome, Plone Foundation, Knowlton Prime, Report Generated, Modules There, Amrician Gangster, Russell Crowe Year
Browse Sample Pages:
Front Cover | Table of Contents | First Pages | Index | Back Cover | Surprise Me!
Search Inside This Book:

What Other Items Do Customers Buy After Viewing This Item?


Tags Customers Associate with This Product

 (What's this?)
Click on a tag to find related items, discussions, and people.
 

Your tags: Add your first tag
 

Sell a Digital Version of This Book in the Kindle Store

If you are a publisher or author and hold the digital rights to a book, you can sell a digital version of it in our Kindle Store. Learn more

Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
Topic:
First post:
Prompts for sign-in
 


Active discussions in related forums
Search Customer Discussions
Search all Amazon discussions
   
Related forums



So You'd Like to...



Look for Similar Items by Category


Look for Similar Items by Subject