Lesson 4.1
Classes and Instances
A class is a template; an instance is one object built from it. The initialiser runs at construction and sets up instance state.
Classes in a language with no enforced privacy. Encapsulation here is a convention the programmer upholds rather than a rule the language imposes, which changes how it must be taught.
Lesson 4.1
A class is a template; an instance is one object built from it. The initialiser runs at construction and sets up instance state.
Lesson 4.2
An attribute set on the class is shared by every instance; one set in the initialiser belongs to that instance alone.
Lesson 4.3
Python marks intended privacy by naming convention rather than enforcement, so encapsulation is a contract between programmers.
Lesson 4.4
Defining the string representation and equality methods makes an object print usefully and compare sensibly.
Work through questions with a tutor and get help with the steps you find difficult.
Get help with this topic