import json def attach(host, port, datafile): response = { 'results': { 'client1': { 'onionAddress': 'crazytime' } } } with open(datafile, 'w') as outfile: json.dump(response, outfile)