SHSubjectHub

Encapsulation and Private Attributes (Python)

OOPA-levelLesson packSubscription

About this resource

Understand why we hide an object's internal data, how to declare private attributes in Python, and how to expose them safely using getter methods.

11 slides.

Lesson outline

  1. What's the Problem?
  2. What is Encapsulation?
  3. Private Attributes in Python
  4. Getters — Exposing Data Safely
  5. BankAccount: Private Attribute + Getter
  6. UML: Visibility Symbols
  7. Encapsulation: What Can Go Wrong?
  8. Coding Practice: Private Attributes (BankAccount)
  9. Lesson Summary
Unit bundleUnit 2A · Encapsulation and Private Attributes
Part of: Unit 2A · Encapsulation and Private Attributes: the whole unitEvery resource in the unit in one zip.

More from Unit 2A · Encapsulation and Private Attributes