PythonClassDefinition AST Python Object
The PythonClassDefinition
object matches a Python class definition.
The astType
value for this node is classdefinition
.
Code Pattern
This AST element captures the following code.
class MyClass:
def __init__(self):
pass
def my_method(self, argument):
pass
Attributes
name
(typeAstString
): name of the classdecorators
: decorators for this class (array of typePythonDecorator
)parentClasses
(array of typeAstString
): parents of the class (e.g. classes inherited from this class)content
(any type that inheritsAstElement
): the content of the class (methods, attributes, etc)
info
To know what is the type of left
or right
, use the astType
to distinguish.
For example, to check if the left node is a string, just use the following code:
if (node.left.astType === "string") {
....
}