What are generics?
Generics are a programming paradigm where any attribute or variable is a function in a language that is not assigned to any specific type. When we speak of type, it is either the variable data type or the function return type.
How are generics connected to metaprogramming?
Metaprogramming deals with the concepts of Python 3 and above, where we can develop scripts or programs that manipulate the objects of Python externally without actually impacting the definition of classes, methods, or functions in a program. Generics are the way in which Python has built the handling of data types for its objects. If we need to change the data type handling in Python from generics to specific types, we can perform it through metaprogramming. To understand how to make specifics work, we need to understand generics with examples. Let’s look at generics in the following section.