두개의 클래스중 하나의 변수값을 변경하려면 어떻게 해야하나요?
조회수 506회
class test1:
def __init__(self):
pass
def test1_1(self):
self.a = 0
print(self.a)
class test2:
def __init__(self):
pass
def test2_2(self):
self.aaa = test1()
self.aaa.a = 9999999999
print(self.aaa)
test1().test1_1()
test2.test2_2()
코드에서 `self.a'
값에 9999999999를 넣고 싶은데 어떤 방식으로 해야 하는지
궁금합니다. 클래스 종속같이 복잡한 작업이 아니라 단순하게 넣는 법이 있을까요?
1 답변
-
상속이라면 바로 인스턴스 변수에 접근하면 됩니다.
아래의 notebook 을 참고하세요.
https://notebooks.azure.com/wincommerce/projects/hashcode/html/7988.ipynb
댓글 입력