Checking whether an object is an instance
In this section, we will look at another function named isinstance
, which can be used to check whether an object is an instance of a particular class. As we are covering introspection in this chapter, we are more focused on what functions are available to introspect an object rather than how these functions can be used further to manipulate or debug a piece of code. Chapter 6, will cover the usage of these functions on metaprogramming along with examples.
In the preceding section, we created a class named Inventory
. In this section, we can continue using the same class and create another object for the class. This is shown as follows:
inventory_fmcg = Inventory(100011,
'Delmonte Ketchup',
'09/04/2021',
&...