Week Two: Building a Library Management System with Python OOP

I’m learning Python, and AI, building projects, experimenting, and figuring things out as I go. I share the challenges, mistakes, and discoveries along the way, documenting my journey and what I learn while exploring programming.
This week, I built a Library Management System using Python, a project that pushed me to explore Object-Oriented Programming (OOP) in a hands-on way. Though terms like inheritance and polymorphism sounded complex at first, creating this functional system helped everything click.
What the Project Taught Me
Through building the library system, I got practical experience in core OOP ideas:
Classes and Objects: I started by creating a Book class as a blueprint. This let me easily create multiple book objects, each with their own title, author, and publication year.
Inheritance: I expanded into subclasses like EBook and PrintedBook, which inherited the basic traits of a Book but added their own details, like file size for e-books and weight for printed ones.
Polymorphism: I implemented a get_description() method that worked for all book types but returned different information based on whether it was an e-book or physical book.
Iterators: made it possible to loop through all books in the library or all books borrowed by a member, just like looping through a list.
Snippet of the project
class Book:
def __init__(self, title, author, year):
self.title = title
self.author = author
self.year = year
def get_description(self):
return f"{self.title} by{self.author} ({self.year})"
class EBook(Book):
def __init__(self, title, author, year, file_size, file_format):
super().__init__(title, author, year)
self.file_size = file_size
self.file_format = file_format
def get_description(self):
return f"EBook: {self.title} ({self.file_format}, {self.file_size}MB)"
Challenges I Faced & How I Solved Them
No learning journey is without its hurdles. Here were mine:
Understanding Variable Scope: I often encountered errors when trying to use a local variable outside its function or accidentally modifying global variables unintentionally. This I understand better my by going through examples given carefully.
Inheritance Issues: I forgot to use super().__init__() when creating subclasses, which meant my EBook and PrintedBook classes weren’t inheriting attributes properly. The error messages pointed me in the right direction.
Implementing Iterators: I kept forgetting to add the __iter__ method to make objects iterable. Testing step-by-step and reading the class note helped me implement it correctly.
As always, patience and repetition were key. Each error was a chance to learn.
OOP seemed overwhelming at first, but breaking it down into smaller concepts made it much easier to grasp. I still have a lot to learn, but projects like this make the process engaging and rewarding.
Two weeks into Python, and I’m starting to see how powerful and organized coding can be. Here’s to more learning and more building! 🚀



