4 Managing Multiple Objects

This chapter will show you techniques for managing any number of objects instantiated from the same class. I’ll first go through an OOP implementation of the bank account example from Chapter 1. The OOP approach allows the data and code of an account to be at the same level, eliminating the need to depend on global data. Then, I’ll split the program into main code that provides a top-level menu and a separate Bank object that manages accounts, in addition to any number of Account objects. We’ll also discuss a better way of handling errors using exceptions.

Bank Account Class

Our bank account class will need, at ...

Get Object-Oriented Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.