Development Category (English)728x90

Class attributes

A class can have attributes (sometimes called variables).

Objects created from a class have all of the parent classes variables.

This allows us to do Object Orientated Programming: we speak about (albeit) virtual objects. Those objects can have unique properties.

Related course:
Python Beyond the Basics – Object-Oriented Programming

Attributes example

Start with a class that has variables.
Create a class product:

Create an object. Then you can set the objects variables:

You can create multiple objects from a class. Each object has unique values for the variables.

Those objects can be used in your program. You can use an objects variables:

You can use a class its constructor to set the objects variables on creation:

Previous Post
Next Post

Leave a Reply