'Abstract class with attributes in Python
I am trying to find a decent way to add attributes in an abstract class. Is the below code alright?
from abc import ABC, abstractmethod
class Vehicle(ABC):
@abstractmethod
def __init__(self,color,regNum):
self.color = color
self.regNum = regNum
class Car(Vehicle):
def __init__(self,color,regNum):
self.color = color
self.regNum = regNum
car = Car("red","EX9890")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
