Chapter 6: Implementing Reflection on Python Objects

In this chapter, we will look at reflection in Python 3 and understand how it is useful in metaprogramming. Reflection is a continuation of introspection, or it can be looked upon as a concept where we can make use of the information we learn from the introspection of properties or attributes of objects in Python and apply them to manipulate the objects, and so perform metaprogramming.

Why reflection? As we know from the previous chapter, introspection is an information-gathering process for Python objects. Reflection is the process of utilizing the information gathered from objects through introspection, and in turn, performing generic operations on them by manipulating them externally to ...

Get Metaprogramming with Python now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.