@carlo.cummerata Для того, чтобы вывести все методы класса, Вы можете воспользоваться методами dir(), callable(), getattr()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
class Axe: def __init__(self, x : int = 0, y : int = 0): self.x = x self.y = y def calc(self): print(self.x + self.y) def higher(self): print(x if x > y or x == y else y) if __name__ == '__main__': axe = Axe() methods = list() for meth in dir(axe): if callable(getattr(axe, meth)) and not (meth.startswith('__')): methods.append(meth) print(methods) # Вывод : # ['calc', 'higher'] |
Для полного списка методов вы можете убрать "meth.startswith('__')"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
class Axe: def __init__(self, x : int = 0, y : int = 0): self.x = x self.y = y def calc(self): print(self.x + self.y) def higher(self): print(x if x > y or x == y else y) if __name__ == '__main__': axe = Axe() methods = list() for meth in dir(axe): if callable(getattr(axe, meth)): methods.append(meth) print(methods) # Вывод : # ['__class__', '__delattr__', '__dir__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'calc', 'higher'] |