Skip to main content
The Class API extends the Symbol API to support methods, attributes, and inheritance hierarchies.

Methods and Method Usages

Classes provide access to their methods and method usages through an intuitive API:
Methods are typed as Function objects.

Class Attributes

Attributes can be accessed and modified easily:

Manipulating Attributes

Attributes expose their own API for modification and analysis:
Attribute operations automatically handle all references, including self.attribute usages in methods and string references.

Working with Inheritance

You can navigate inheritance hierarchies with APIs including:
Likewise, you can modify inheritance by accessing: Which return lists of Name objects.
When working with inheritance, use max_depth to control how far up the inheritance chain to look. max_depth=0 means current class only, max_depth=None means traverse entire hierarchy.
Codegen handles both internal and external parent classes (like stdlib classes). The superclasses property follows the language’s MRO rules for method resolution.

Method Resolution Order (MRO)

Codegen follows the target language’s method resolution order (MRO) for inheritance: