Expert Python Programming

This is the perfect book for refining your Python skills through learning best practices and the latest development techniques. Packed with real-world examples and written by an expert, this is the authoritative tutorial.

Expert Python Programming

Progressing

Tarek ZiadéSeptember 2008

This is the perfect book for refining your Python skills through learning best practices and the latest development techniques. Packed with real-world examples and written by an expert, this is the authoritative tutorial.

Who This Book Is For

This book is for Python developers who are already building applications, but want to build better ones by applying best practices and new development techniques to their projects.

The reader is expected to have a sound background in Python programming.

Table of Contents

Chapter 1: Getting started

Installing Python

The Python Prompt

Installing setuptools

Working Environment

Summary

Chapter 2: Syntax Best Practices—Below the Class Level

List Comprehensions

Iterators and Generators

Decorators

with and contextlib

Summary

Chapter 3: Syntax Best Practices—Above the Class Level

Subclassing Built-in Types

Accessing Methods from Superclasses

Best Practices

Descriptors and Properties

Slots

Meta-programming

Summary

Chapter 4: Choosing Good Names

PEP 8 and Naming Best Practices

Naming Styles

Naming Guide

Best Practices for Arguments

Class Names

Module and Package Names

Working on APIs

Useful Tools

Summary

Chapter 5: Writing a Package

A Common Pattern for All Packages

The Template-Based Approach

Creating the Package Template

Development Cycle

Summary

Chapter 6: Writing an Application

Atomisator: An Introduction

Overall Picture

Working Environment

Writing the Packages

Distributing Atomisator

Dependencies between Packages

Summary

Chapter 7: Working with zc.buildout

zc.buildout Philosophy

Releasing and Distributing

Summary

Chapter 8: Managing Code

Version Control Systems

Continuous Integration

Summary

Chapter 9: Managing Life Cycle

Different Approaches

Defining a Life Cycle

Setting Up a Tracking System

Summary

Chapter 10: Documenting Your Project

The Seven Rules of Technical Writing

A reStructuredText Primer

Building the Documentation

Make Your Own Portfolio

Summary

Chapter 11: Test-Driven Development

I Don't Test

I Do Test

Summary

Chapter 12: Optimization: General Principles and Profiling Techniques

The Three Rules of Optimization

Optimization Strategy

Finding Bottlenecks

Summary

Chapter 13: Optimization: Solutions

Reducing the Complexity

Multithreading

Multiprocessing

Caching

Summary

Chapter 14: Useful Design Patterns

Creational Patterns

Structural Patterns

Behavioral Patterns

Summary

What You Will Learn

Set up a productive development environment

Customize the Python prompt and deploy setuptools

Write efficient syntax: iterators, generators, and decorators

Build arguments by design and follow the best practices for working on API

Build, release, and distribute your applications

Write an application based on several eggs

Distribute and deploy your application with zc.buildout

Build and release your packages and set up a development cycle

Manage your code with distributed version control and continuous integration

Use an iterative and incremental approach to write software

Practice Test-Driven Development

Profile and optimize your code to speed up your programs

Apply design patterns to your applications

Chapter 1, Getting Started, explains how to install Python and makes sure all readers have the closest, standardized environment.

Chapter 2, Syntax Best Practices' Below the Class Level, presents iterators, generators, descriptors and so on, in an advanced way.

Chapter 3, Syntax Best Practices' Above the Class Level, is also about syntax best practices, but focuses on above the class level.

Chapter 4, Choosing Good Names, is an extension to PEP 8 with naming best practices, but also gives tips on designing good APIs.

Chapter 5, Writing a Package, explains how to write a package and how to use code templates, then focuses on how to release and distribute your code.

Chapter 6, Writing an Application, extends Chapter 5 by describing how a full application can be written. It demonstrates it through a small case study called Atomisator.

Chapter 7, Using zc.buildout, is about zc.buildout, a system for managing a development environment and releasing applications, which is widely used in the Zope and Plone community and is starting to be used outside the Zope world.

Chapter 8, Managing Code, shows how your project code base can be managed with distributed instead of centralized version control and explains how to set up continuous integration.

Chapter 9, Managing Life Cycle, presents how to manage software life cycle through an iterative and incremental approach.

Chapter 10, Documenting Your Project, is about documentation and gives tips on technical writing and how Python projects should be documented.

Chapter 11, Test-Driven Development, explains Test-Driven Development and the tools that can be used to do it.

Chapter 14, Useful Design Patterns, ends the book with a set of design patterns and when to use them.

In Detail

Python is a dynamic programming language, used in a wide range of domains by programmers who find it simple, yet powerful. From the earliest version 15 years ago to the current one, it has constantly evolved with productivity and code readability in mind.

Authors

Tarek Ziadé

Tarek Ziadé is CTO at Ingeniweb in Paris, working on Python, Zope, and Plone technology and on Quality Assurance. He has been involved for 5 years in the Zope community and has contributed to the Zope code itself.

Tarek has also created Afpy, the French Python User Group and has written two books in French about Python. He has gave numerous talks and tutorials in French and international events like Solutions Linux, Pycon, OSCON, and EuroPython.

Alerts & Offers

Series & Level

We understand your time is important. Uniquely amongst the major publishers, we seek to develop and publish the broadest range of learning and information products on each technology. Every Packt product delivers a specific learning pathway, broadly defined by the Series type. This structured approach enables you to select the pathway which best suits your knowledge level, learning style and task objectives.

Learning

As a new user, these step-by-step tutorial guides will give you all the practical skills necessary to become competent and efficient.

Beginner's Guide

Friendly, informal tutorials that provide a practical introduction using examples, activities, and challenges.

Essentials

Fast paced, concentrated introductions showing the quickest way to put the tool to work in the real world.

Cookbook

A collection of practical self-contained recipes that all users of the technology will find useful for building more powerful and reliable systems.

Blueprints

Guides you through the most common types of project you'll encounter, giving you end-to-end guidance on how to build your specific solution quickly and reliably.

Mastering

Take your skills to the next level with advanced tutorials that will give you confidence to master the tool's most powerful features.

Starting

Accessible to readers adopting the topic, these titles get you into the tool or technology so that you can become an effective user.

Progressing

Building on core skills you already have, these titles share solutions and expertise so you become a highly productive power user.