Search for tag: "initializer"

Lesson 27.3 The GameApp Class

In this video we introduce the GameApp class, which is a class written by your instructor. In the last assignment you will be creating a subclass of the class to run your game. This video highlights…

From  Hannah Lee 85 plays

Lesson 25.5 Custom Error Types

Now that we can raise an error of any type, it is time to make our own error types. In this video we show that this is incredibly simple, and needs almost no code.

From  Hannah Lee 60 plays

Lesson 23.7 Class Methods

Operator overloading is not the only important abstraction tool. In this video we introduce the concept of class methods, which are necessary to add new constructors to a class. These new…

From  Hannah Lee 81 plays

Lesson 22.8 Subclass Initializers

In this video we show that thte primary purpose of the super function is in the initializer method of the subclass. That is because we cannot guarantee that all of the attributes for the parent class…

From  Hannah Lee 67 plays

Lesson 22.6 Method Overriding

Subclasses inherit all of the methods of their parent. But suppose you do not want to use the inherited version of a method, but want to define a new one instead? In this video we talk about the…

From  Hannah Lee 69 plays

Zoom Oct. 29. Classes

In this presentation, we review the class definition. We look at both the syntax (what must be present for the definition to work) and the semantics (how it is processed in Python).Most of this class…

From  Hannah Lee 29 plays

Lesson 21.6 Immutable Attributes

Getters and setters have another advantage in that they allow us to completely disable to any changes to an attribute. This allows us to separate attributes into mutable and immutable attributes,…

From  Hannah Lee 86 plays

Lesson 21.4 Invariant Enforcement

We know how to enforce preconditions, but how do we force invariants for our attributes? As we see in this video, we do it much the same as for preconditions. But that is because we are going to…

From  Hannah Lee 100 plays

Lesson 21.3 Interface Implementation

Once you have the interface to a class, it is time to start writing code. As we see in this video, the idea is much the same as writing functions. However, attributes – and specifically…

From  Hannah Lee 87 plays

Lesson 21.1 Interface vs Implementation

When we implement (or define) a function, we are given a specification and we complete the rest of the body to match the specification. We will do the same thing for classes as well. But as we see in…

From  Hannah Lee 142 plays

Lesson 20.10 Representation Methods

When we first introduced objects, we talked about the concept of object representation. But how does Python know how to use this representation. In this video, we see that this is the result of…

From  Hannah Lee 74 plays

Lesson 20.9 Optional Arguments

Unlike other programming languages, a Python class has only one constructor, If we want to give the user more flexibility when creating objects, we should make certain arguments optional. In this…

From  Hannah Lee 85 plays

Lesson 20.8 The None Value

We have seen the None value used in several previous videos. But in this video we finally introduce it formally. In particular, we show why it is so commonly used in object initialization.

From  Hannah Lee 83 plays

Lesson 20.7 Intializers

In this video, we introduce the most important method definition in any class: the initializer. The initializer is responsible for creating all the attributes so that the user does not need to worry…

From  Hannah Lee 112 plays