Skip to main content
Version: Next

Review for Quiz 4

Properties

It is recommended to review these topics:

  • @property and *.setter decorators
  • Accessing attributes named using _ or __

Inheritance and abstract methods

It is recommended to review these topics:

  • What @abstractmethod does

  • 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:

IterableIterator
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.