def __init__(self, filename, **kw):
        """ The constructor takes the filename and some options.

            backup -- boolean indicating whether you want a backup file
                (default is yes)
        """
        self.filename = filename
        self.do_backup = kw.get('backup', 1)

        self.stream = None
        self.basename, ext = os.path.splitext(self.filename)
 The constructor takes the filename and some options.

            backup -- boolean indicating whether you want a backup file
                (default is yes)
        
recipes/Python/56037_Safely_morph_a_file_inplace/recipe-56037.py