solid-principles

Python understanding Liskov Substiution Principle

Python understanding Liskov Substiution Principle Question: In this example, am I violating LSP? Since straight up replacing the last two lines with an instance of a subclass will give me an error(as wage isn’t initialised)? person_1 = Employee(‘Brad’) person_1.print_name() @dataclass class Person: name: str def print_name(self): print(self.name) @dataclass class Employee(Person): wage: int person_1 = Person(‘Brad’) …

Total answers: 3