2.17. Classes

A class is merely a container for static data members or function declarations, called a class's attributes. Classes provide something which can be considered a blueprint for creating “real” objects, called class instances. Functions which are part of classes are called methods. Classes are an object-oriented construct that are not required at this stage in learning Python. However, we will present it here for those who have some background in object-oriented methodology and would like to see how classes are implemented in Python.

How to Declare a Class

							class class_name[( base_classes_if_any)]:
    "optional documentation string"
    static_member_declarations
							method_declarations
						

Classes are declared using the class keyword. If a subclass ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.