How do I change the variable value of one of the two classes?

Asked 1 years ago, Updated 1 years ago, 114 views

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()

I want to put 999999999999999 in the value of 'self.a' in the code, but I don't know how to do it I'm curious. Is there a simple way to put it in, not a complicated task like class dependency?

pyqt5 python pyqt

2022-09-21 20:04

1 Answers

If you are inheriting, you can immediately access the instance variable.

Please refer to the notebook below.

https://notebooks.azure.com/wincommerce/projects/hashcode/html/7988.ipynb


2022-09-21 20:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.