October 22, 2024
Chicago 12, Melborne City, USA
python

How do I get methods with arguments in a Python class using dir() while keeping original order of methods?


The dir() method print the methods in alphabetical order. How can I keep the original order of the methods in my class?

Here’s my code

            return [(m, getattr(PythonClass, m).__code__.co_varnames)
                    for m in dir(PythonClass)]

Thanks!



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video