def opentemp(self):
        """ Open a temporary file for writing and return an open stream.
        """
        assert not self.stream, "Write stream already open"

        self.stream = open(self.__tempfile(), "wt")

        return self.stream
 Open a temporary file for writing and return an open stream.
        
recipes/Python/56037_Safely_morph_a_file_inplace/recipe-56037.py