Book Image

Python Essentials

By : Steven F. Lott
Book Image

Python Essentials

By: Steven F. Lott

Overview of this book

Table of Contents (22 chapters)
Python Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 11. Class Definitions

A Python object is an instance of a class. A class defines the behavior of an object via the method functions. In this chapter, we'll look at creating our own classes and our own objects. We'll start by looking at the basics of creating classes and objects. Once we've seen the essential tools, we can summarize some of the ways that we can class definitions to create objects, and how objects should interact to create the behavior we intend.

We'll look at some elements of more sophisticated class definition. Advanced topics will include the concepts of class methods and static methods. An entire book can be written on advanced object-oriented programming in Python, so we'll take a broad, but shallow, approach to looking at class definitions.

We'll also look at the built-in abstract base classes. We can use these to simplify our own class definitions. In many cases, we have container-like classes that can leverage a base class, saving us some programming and assuring...