#!/usr/bin/python3 import tempfile import os import importlib while 1: fd, path = tempfile.mkstemp(suffix='.py', dir='', text=True) f = os.fdopen(fd, 'wt') f.close() print("Wrote {}".format(os.path.basename(path))) modname = os.path.basename(path[:-3]) importlib.import_module(modname) print(" Successfully imported {}".format(modname)) os.remove(path)