Using Constructor Between Classes at Python

This sample is for using constructor between classes at Python.

Sample :

class test1:

    def __init__(self):
        self.msg = "sample text"


class test2:

    def __init__(self):
        self.msg = test1().msg


print(test2().msg)

>>> sample text

 Share!