Defining a Class

Within a Python class, both variables and methods can be defined. Unlike in Java, in Python you can define any number of public classes per source file (or module). Therefore, a module in Python can be thought of similar to a package in Java.

In Python, classes are defined using the class statement. The class statement has the following form:

class name (superclasses): statement 

or

class name (superclasses): 
    assignment
    .
    .
    function
    .
    .

When you define a class, you have the option to provide zero or more assignment statements. These create class attributes that are shared by all instances of the class. You can also provide zero or more function definitions. These function definitions create methods. The superclasses list is optional.

The class name should be unique in the same scope, that is within a module, function or class. You can define multiple variables to reference the same class.