Junyeop Na Dev Blog
Junyeop Na Dev Blog
  • Archives
  • All Categories
  • All Tags

python

1 article

computer vision Machine Learning ML networking python RAG
pythonoop.png

Python OOP Features

Saturday, Apr 12, 2025

Studying on OOP Features of Python Programming Language 1. Class Method for Polymorphism class Animal: def __init__(self, name): self.name = name def say(self): pass class Cat: def __init__(self, name): super().__init__(name) def say(self): print(f"{self.name}, a Cat") class Dog: def __init__(self, name): super().__init__(name) def say(self): print(f"{self.name}, a Dog") class AnimalContainer: def __init__(self): self.animals = [] def create_animals(self, names): for name in names: animal = Cat(name) animal.say() self.animals.append(animal) With the current implementation, if you want to implement create_animals function for Dog, you have to create a new class or a new function for Dogs.
Jun Yeop(Johnny) Na
Jun Yeop(Johnny) Na
6 minute read

© 2024 - 2025 Junyeop Na Dev

🌱 Powered by Hugo with theme Dream.

© 2024 - 2025 Junyeop Na Dev

🌱 Powered by Hugo with theme Dream.