I am trying to access a function from within a class that is within a different file.
My layout is:
Directory
-> ClassFile.py
-> _AFile.py
in ClassFile:
class TestClass:
from ._AFile import test_1, test_2, test_3
def __init__(self):
def RunAllTests(self):
self.test_1()
self.test_2()
self.test_3()
@staticmethod
def __DoSomething(a, b):
return a + b
in _AFile:
def test_1(self):
self.__DoSomething
def test_2(self):
self.__DoSomething
def test_3(self):
self.__DoSomething
This is what I want to do but cannot as I get: AttributeError: 'TestClass' object has no attribute '__DoSomething'
How can I access the static method from TestClass within AFile?
_AFile, atleast the member listing?test_1exists in_AFile, there is no__DoSomethingin_AFile. You'll have to importTestClassin_AFile. Also you'll have to call it asTestClass.__DoSomethingas it is static.