On 22/06/13 02:42, Matt D wrote:

             if dlg.ShowModal() == wx.ID_OK:
                 path = dlg.GetPath()
                 mypath = os.path.basename(path)
                 with open(mypath, "a") as f:
                 f.writelines(self.log_array)

so thats how i used what you said, "with open() as f:".  is this the
right way to open the file?

You need to indent the writelines() call so its inside
the 'with' block.

                  with open(mypath, "a") as f:
                       f.writelines(self.log_array)

This means you don't need to call f.close() each time - which you were missing from your earlier code.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to