python 获取类中除内置方法外的所有方法名

#!/usr/bin/env python
# !-*- coding:utf-8 -*-

class Menu:

def __init__(self):
pass

def updateProject(self):
pass

def restartProject(self):
pass

def restartTomcat(self):
pass

def stopTomcat(self):
pass

def startTomcat(self):
pass

def methods(self):
return(list(filter(lambda m: not m.startswith("__") and not m.endswith("__") and callable(getattr(self, m)), dir(self))))

if __name__ == '__main__':
print(Menu().methods())

  

posted @ 2018-11-15 11:30  skychi  阅读(7107)  评论(0编辑  收藏  举报