List below is my project structure.
├── folder1
├── test.py
├── folder2
├── A.py
├── folder3
├── A.py
A.py
in folder2
and folder3
are the same except self.key
#folder2
class TestAPI():
def __init__(self):
self.key = 50
#folder3
class TestAPI():
def __init__(self):
self.key = 100
In test.py
, the code is
import sys
root_path = '/user/my_account'
sys.path.insert(0, root_path + '/folder2')
from A import TestAPI
test_api = TestAPI()
print(test_api.key)
sys.path.insert(0, root_path + '/folder3')
from A import TestAPI
test_api = TestAPI()
print(test_api.key)
print(sys.path)
While executing test.py
, it returns 50
,50
, ('/user/my_account/folder3', '/user/my_account/folder2')
. Why the second time from A import TestAPI
not from folder3
but folder2
?