The dir()
function return a list of the methods but:
The resulting list is sorted alphabetically
I want to know which ones are but not sorted alphabetically. I use the name to help to understand what does this method. I use name like game_start, game_battle, game_map. I could change the name to start, battle, map but if I want to use the same submit method for all this other methods in a tkinter app. So I need the name of the methods to eval in the order of declaration.
Is there any other workaround?
example:
class hi(object):
def __init__(self):
self.name="LLopis"
def question(self):
print("Question?")
def answer(self):
print("Answer")
The result of dir(hi)
is:
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'answer', 'question']
I want a function that return instead (or whatever is the internal order of the private methods, but by order of finding):
['__init__', 'question', 'answer']
Edit: I do not care about attributes like hi.name, therefore although this question is related it is not an exact duplicate.