[Solved] Return the list is empty python [closed]


As is, your code shoud do nothing.

I guess you are calling Main() in some way. But the function doObjects is never called. Moreover, you may have forgotten to add self.list1 = list1 in your function definition

The good way to do this could be first to add to your script at the end:

M = Main()
return_list = M.doObjects()
print return list

And your Main function could/should be:

class Main(list):

    def doObjects(self, list1):
        self.list1 = list1
        mib = Mib()
        self.list1.append(MibObject('MY-MIB', 'testDescription', mib.getTestDescription))
        self.list1.append(MibObject('MY-MIB', 'testCount', mib.getTestCount))
        return self.list1

But still, list1 is defined outside Main, I guess you should rethink/redesign your workflow.

solved Return the list is empty python [closed]