Answers for "creating an object from the getter of a different class"

1

creating an object from the getter of a different class

class Example():
    def __init__(self):
        self.test = 25

    def getTest(self):
        print(self.test)


class Example2():
    def createObject(self):
        return Example()

abc = Example2() #abc is an object created from the Example2 class

xyz = abc.createObject() #xyz is an obejct of the Example class

xyz.getTest() # this outputs 25
Posted by: Guest on June-10-2020

Code answers related to "creating an object from the getter of a different class"

Python Answers by Framework

Browse Popular Code Answers by Language