I want to print the properties and methods of a class into the console with GDScript. In Python, this can be done with the print(dir(variable)) method.

Is there an analogous function in GDScript?


1 Answer 1


I made my own dir function and it works OK.

func dir(class_instance):
    var output = {}
    var methods = []
    for method in class_instance.get_method_list():
    output["METHODS"] = methods
    var properties = []
    for prop in class_instance.get_property_list():
        if prop.type == 3:
    output["PROPERTIES"] = properties

    return output
  • \$\begingroup\$ this still works well even in Godot 4! \$\endgroup\$
    – Zion
    Commented Jul 13, 2023 at 14:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .