패키지에 여러 클래스에서 모든 기능을 검색 .py, b.py, c.py파이썬은 나는 현재 같은 패키지 구조를 가지고
from os import listdir
files = listdir(directory_to_common)
for f in files:
if '.py' in f and '__' not in f:
module_name = f.split(.)[0]
module = __import__(module_name)
모듈을 성공적으로 가져올 수 있습니다. 내가
inspect.getmembers(module)
을 사용하지만은 않은 필요한 많은 정보를 반환보다
. 여기에서 a.py, b.py, c.py의 함수를 어떻게 검색합니까?
#a.py, b.py, c.py has similar structure as follows:
class A:
def __init__(self):
.....
def method1_in_a(self):
.....
def method2_in_a(self):
.....
당신이 "기능"에 의해 무엇을 의미합니까? 'def'를 사용하여 정의 된 함수는 무엇입니까? '함수'의 인스턴스? 모든 전화 걸기? – Goyo
@ Goyo 모든 메소드 method1_in_a, method2_in_a 등을 ech py 파일의 각 클래스에 반환하는 것을 의미합니다. –