Creating dynamic classes
In this section, let’s look at how to create classes dynamically with different names and different attributes by making use of the built-in functions of type
and globals
. To explore this concept further, we will first create one dynamic class using the type
function:
Product = type('Product', (object,), {'branchID' : 202,
'productId': 100001,
'productName': 'Refrigerator',
'productBrand...