Summary
In this chapter, we have learned how to examine function objects in Python using the concept of reflection and the corresponding applications of reflection, in which we saw how to implement reflection using built-in functions such as id
, callable
, hasattr
, isinstance
, issubclass
, and property
on various Python objects, and we also learned how to apply them to our core example. From all of these concepts, we learned how to examine Python objects such as classes, methods, and functions. From the examples covered under each topic, we also learned how to apply reflection in practical use cases.
Similar to other chapters covered in this book, this chapter, which covered the concept of reflection, also covered changing the behavior of Python objects externally using metaprogramming.
In the next chapter, we will be looking at the concept of generics with some interesting examples.