Using issubclass to modify a class
In this section, we will look at the issubclass
built-in function. This function can be used to apply reflection on classes that are inherited by one or more parent classes or superclasses. This function is used to verify whether a class is a subclass of a specific parent and then modify the class accordingly.
Let’s begin by creating two classes with a simple set of variables. The classes will be named StoreCoupon
and ManufacturerCoupon
:
class StoreCoupon:
product_name = "Strawberry Ice Cream"
product_category = "Desserts"
brand = "ABCBrand3"
store = "Los Angeles Store"
expiry_date = "10/1/2021"
quantity = 10
class ManufacturerCoupon:
product_name = "Strawberry Ice Cream"
...