Skip to content

carlbordum/dynamic-inheritance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

dynamic inheritance

A true classic when it comes to OOP patterns; refer to your text book.

import random


class Cat:
    def speak(self):
        print('Meow!')


class Dog:
    def speak(self):
        print('Woof!')


class RandomAnimal(random.choice((Cat, Dog))):
    pass


if __name__ == '__main__':
    RandomAnimal().speak()
Woof!

(please let me know (e.g. submit pr) if you have other awesome ideas)

Releases

No releases published

Packages

No packages published