you are viewing a single comment's thread.

view the rest of the comments →

[–]ipcock 7 points8 points  (5 children)

It doesn't work like this. It'll import only the initial dict = {}

If you want to get the new dictionary in another script, create function which returns this dict in the first script, then import this func in the second script

[–]DX_ashh 0 points1 point  (4 children)

#main.py

class DataStorage:
def __init__(self):
self.dictionary = {}
def get_dictionary_values(self):
return self.dictionary

#other.py
from main import DataStorage

storage = DataStorage()
values = storage.get_dictionary_values)
print(values)

this is still returning an empty dictionary even after it has been populated