code: def write(self, file, text, subvars={}, trim_leading_lf=True):
          '''write to a file with variable substitution'''
          file.write(self.substitute(text, subvars=subvars, trim_leading_lf=trim_leading_lf)f write(self, file, text, subvars={}, trim_leading_lf=True):
          '''write to a file with variable substitution'''
          file.write(self.substitute(text, subvars=subvars, trim_leading_lf=trim_leading_lf))
docs: write to a file with variable substitution