def write_to_file(self, codelisting): # override write to file, in this chapter cwd is root tempdir print('writing to file', codelisting.filename) write_to_file(codelisting, os.path.join(self.tempdir)) print('wrote', open(os.path.join(self.tempdir, codelisting.filename)).read())