Review for Quiz 4
Properties
It is recommended to review these topics:
@propertyand*.setterdecorators- Accessing attributes named using
_or__
Inheritance and abstract methods
It is recommended to review these topics:
-
What
@abstractmethoddoes -
Rules for when you can instantiate a class
-
What is inherited by subclasses (methods and attributes that aren't named with two underscores)
-
Overwriting inherited methods
-
Calling a superclass's method or constructor
Iterator and Comparable
It is recommended to review this table:
| Iterable | Iterator | |
|---|---|---|
| Protocol's required methods | __iter__(self) -> Iterator[T]: returns an iterator | __next__(self) -> T: returns the next element or raises StopIteration __iter__(self) -> Iterator[T] : returns itself |
abc interface's required methods | __iter__(self) -> Iterator[T] (same as protocol) | __next__(self) -> T (same as protocol) not __iter__(self) -> Iterator[T] because it's aleady there |
- Implementing the Comparable protocol
- Checking for inconsistencies between implemented Comparable methods
- Rules for using
<,>, etc.