Python class keyword

Instance

Create a class named "Person":

class Person:
  name = "Bill"
  age = 63

Run Instance

Definition and Usage

The 'class' keyword is used to create classes.

Classes are like object constructors. See the following example to understand how to use classes to create objects.

More Examples

Instance

Create object p1 using the class from the previous example:

p1 = Person()
print(p1.name)

Run Instance

related pages

Please find in our Python Class/Object Tutorial More about classes and objects in middle school.