1
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

6
\$\begingroup\$

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(): methods.append(method.name) output["METHODS"] = methods var properties = [] for prop in class_instance.get_property_list(): if prop.type == 3: properties.append(prop.name) output["PROPERTIES"] = properties return output 
\$\endgroup\$
1
  • \$\begingroup\$ this still works well even in Godot 4! \$\endgroup\$ Commented Jul 13, 2023 at 14:35

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.