I have a __main__
function where I initialize a lot of variables that are to be used in my program, later on. I have a problem where a variable that I temporarely declare as None in the outer scope, is assigned an object of SomeClass, but due to scoping rules I cannot access it's content in the outer scope. Because the constructor of SomeClass demands an argument to be passed, I cannot simply declare myObject to be foo.bar.SomeClass
to begin with. So what must I do in order to get access to the attributes in foo.bar.SomeClass?
Codewise it looks like this:
myObject = None
def setUp():
... lots of initialization ...
myObject = foo.bar.SomeClass(init_variable)
if __name__ == "__main__":
setUp()
myObject.member1 #throws AttributeError: 'NoneType' object has no attribute member1