[Tutor] Need help appending data to a logfile

Wayne Werner wayne at waynewerner.com
Fri Jun 28 23:05:54 CEST 2013


On Fri, 28 Jun 2013, Alan Gauld wrote:

> On 28/06/13 20:54, Matt D wrote:
>
>> def openFile(self, evt):
>>      with wx.FileDialog(self, "Choose a file", os.getcwd(), "",
>>                         "*.txt*", wx.SAVE) as dlg:
>>         if dlg.ShowModal() == wx.ID_OK:
>>              path = dlg.GetPath()
>>              mypath = os.path.basename(path)
>>              with open(mypath, "a") as f:
>>                  f.write(self.logfile)
>>                  self.logfile.close()
>
>
> But I must say this seems like an inordinately complicated way
> of doing things and quite out of the norm for other applications.
> Can you back up several steps and explain again what exactly you
> are trying to achieve? What is the user experience supposed to
> be? What is being recorded where and why? How does a user
> interact with it?
>
> Logging is such a well established process for most applications that
> one of a very few patterns are usually followed. You seem to be
> trying to invent a whole new paradigm here? (And that may not be
> a bad thing, but we should at least understand why it's needed!)

Especially when the Python standard library has an extremely powerful 
logging module. Or logbook.

-W


More information about the Tutor mailing list