PacktLib: Python 3 Object Oriented Programming

Python 3 Object Oriented Programming

Credits

About the Author

About the Reviewers

Preface

Object-oriented Design

Object-oriented?

Objects and classes

Specifying attributes and behaviors

Hiding details and creating the public interface

Composition and inheritance

Case study

Exercises

Summary

Objects in Python

Creating Python classes

Modules and packages

Who can access my data?

Case study

Exercises

Summary

When Objects are Alike

Basic inheritance

Multiple inheritance

Polymorphism

Case study

Exercises

Summary

Expecting the Unexpected

Raising exceptions

Handling exceptions

Exception hierarchy

Exceptions aren't exceptional

Case study

Exercises

Summary

When to Use Object-oriented Programming

Treat objects as objects

Using properties to add behavior to class data

Managing objects

Case study

Exercises

Summary

Python Data Structures

Empty objects

Tuples and named tuples

Dictionaries

Lists

Sets

Extending built-ins

Case study

Exercises

Summary

Python Object-oriented Shortcuts

Python built-in functions

Comprehensions

Generators

An alternative to method overloading

Functions are objects too

Case study

Exercises

Summary

Python Design Patterns I

Design patterns

Decorator pattern

Observer pattern

Strategy pattern

State pattern

Singleton pattern

Template pattern

Exercises

Summary

Python Design Patterns II

Adapter pattern

Facade pattern

Flyweight pattern

Command pattern

Abstract factory pattern

Composite pattern

Exercises

Summary

Files and Strings

Strings

File IO

Storing objects

Exercises

Summary

Testing Object-oriented Programs

Why test?

Unit testing

Testing with py.test

How much testing is enough?

Case Study

Exercises

Summary

Common Python 3 Libraries

Database access

Pretty user interfaces

XML

CherryPy

Exercises

Summary

Index