Introducing built-in functions used in reflection
To understand reflection and the usage of Python’s built-in functions to perform reflection, we will continue making use of our core example of ABC Megamart throughout this chapter. We will be specifically looking at the concept and examples based on coupons in a retail store throughout this chapter. Coupons are a technique used by retail stores or manufacturers to promote their products among consumers. Coupons are generated and posted through various modes of advertisements, and they are used to attract customers to a specific store or product.
We will make use of the same set of built-in functions as in introspection, to apply reflection on Python objects:
id()
eval()
callable()
hastattr()
getattr()
isinstance()
issubclass()
property()
Reflection on Python objects helps in the metaprogramming of these objects using the built-in functions that can introspect Python objects, and...