import os
import json
from os.path import expanduser
home = expanduser("~")
data_file = os.path.join(home, '.myprogramdata')
if os.path.isfile(data_file):
fd = open(data_file, 'r')
data = json.loads(fd.read())
else:
data = get_data_from_web() # логика получения данных из сети
fd = open(data_file, 'w')
fd.write(lson.dumps(data))
fd.close()
return data