#!/usr/bin/env python3 from string import Template import os import sys import datetime d = input("What is the due date? ") i = 1 while os.path.exists(f'pset{i}'): i += 1 s = { 'number': i, 'date': d } with open(f'.template/template.tex', 'r') as f: src = Template(f.read()) result = src.substitute(s) os.mkdir(f'pset{i}') with open(f'pset{i}/pset{i}.tex', 'w') as f: f.write(result)