import os current_dir = os.getcwd() file = current_dir + filename if not os.path.exists(file): with open(file, 'w'): pass