Re: [Tutor] Need help appending data to a logfile

2013-06-30 Thread Alan Gauld
On 30/06/13 16:42, Matt D wrote: im sorry i don't understand how to pass the file name from the open dialog into the update method? I'm sorry i just don't get it. so if the user opened file is 'handle' like this?: OK, technically you probably donb;t want to pasws it into the metjod but to

Re: [Tutor] Need help appending data to a logfile

2013-06-30 Thread Alan Gauld
On 30/06/13 15:04, Matt D wrote: that sounds ideal, but i have not found a way to pass the user selected file into the loop that writes the data without opening another file. Don;t pass the file pass the fgile *name* Then inside the update method open the file(in append mode) and write the lat

Re: [Tutor] Need help appending data to a logfile

2013-06-30 Thread Alan Gauld
On 30/06/13 04:41, Matt D wrote: So i have a program that gets pickled data from a thread and displays the data (9 strings) in TextCtrl fields in the UI. The fact that it is a UI is largely irrelevant apart from the fact that it forces an event driven architecture. When the pickle is receiv

Re: [Tutor] Need help appending data to a logfile

2013-06-29 Thread Dave Angel
On 06/29/2013 09:38 PM, Steven D'Aprano wrote: I haven't read this entire thread, but the bits I have read lead me to think that Matt has tangled himself up in a total confused mess. It's *not this hard* to write status messages to a log file, the log module does all the work. Can anyone w

Re: [Tutor] Need help appending data to a logfile

2013-06-29 Thread Steven D'Aprano
On 30/06/13 10:51, Alan Gauld wrote: On 29/06/13 16:00, Matt D wrote: with tempfile.NamedTemporaryFile('a+t',) as tf: self.logfile = tf This could give problems. with guarantees to close the file at the end of the block. But you have assigned it to self.logfile. So when the fi

Re: [Tutor] Need help appending data to a logfile

2013-06-29 Thread Alan Gauld
On 29/06/13 16:00, Matt D wrote: with tempfile.NamedTemporaryFile('a+t',) as tf: self.logfile = tf This could give problems. with guarantees to close the file at the end of the block. But you have assigned it to self.logfile. So when the file is closed (and tempfile then delete

Re: [Tutor] Need help appending data to a logfile

2013-06-29 Thread Dave Angel
On 06/29/2013 08:26 AM, Matt D wrote: Matt probably read somewhere about an interface like tempfile.TemporaryFile where the file has no explicit name, and will be deleted from disk, and the space reused as soon as it is closed. I don't believe he's using such an interface, however. Yes

Re: [Tutor] Need help appending data to a logfile

2013-06-28 Thread Dave Angel
On 06/28/2013 08:04 PM, Alan Gauld wrote: On 28/06/13 22:25, Matt D wrote: Python UI. I have a thread that waits on new data and when it comes in it gets displayed in TextCtrl fields. every time this happens my logger puts those values into a text file one row at a time. this how i open and

Re: [Tutor] Need help appending data to a logfile

2013-06-28 Thread Alan Gauld
On 28/06/13 22:25, Matt D wrote: Python UI. I have a thread that waits on new data and when it comes in it gets displayed in TextCtrl fields. every time this happens my logger puts those values into a text file one row at a time. this how i open and the file for logging data: # open a f

Re: [Tutor] Need help appending data to a logfile

2013-06-28 Thread Alan Gauld
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)

Re: [Tutor] Need help appending data to a logfile

2013-06-28 Thread Steven D'Aprano
On 28/06/13 23:18, Matt D wrote: what if i did some thing like this i saw on stackoverflow: f = open("bigfile.txt", "w") That clears any existing content of bigfile.txt, and opens it for writing. Do you intend to clear the content? for tempfile in tempfiles: What is in tempfiles? A list

Re: [Tutor] Need help appending data to a logfile

2013-06-28 Thread Dave Angel
On 06/28/2013 07:27 AM, Matt D wrote: As for the shutil.copy() function, how complex can it be? It takes two file names, source and destination. It does not need a with statement since it wants strings, not file handles. You might get into trouble on some OS's with the source file already o

Re: [Tutor] Need help appending data to a logfile

2013-06-27 Thread Dave Angel
On 06/27/2013 05:09 PM, Matt D wrote: On 06/27/2013 12:54 PM, Dave Angel wrote: On 06/27/2013 12:33 PM, Matt D wrote: I forgot to mention i have the 'with open(mypath, "a") as f: commented out because it was making an indentation error that i could not fix. It was indented, and shoul

Re: [Tutor] Need help appending data to a logfile

2013-06-27 Thread Dave Angel
On 06/27/2013 12:33 PM, Matt D wrote: I forgot to mention i have the 'with open(mypath, "a") as f: commented out because it was making an indentation error that i could not fix. It was indented, and should not have been. The extra indentation FOLLOWS the with statement, it's not correc

Re: [Tutor] Need help appending data to a logfile

2013-06-27 Thread Dave Angel
On 06/27/2013 10:55 AM, Matt D wrote: On 06/27/2013 10:36 AM, Matt D wrote: You asked about a "save-as" feature. Why isn't that as simple as copying the current contents of the saved csv file? Or do you not know how you would go about copying? Hi. So I have the logger working, meaning t

Re: [Tutor] Need help appending data to a logfile

2013-06-24 Thread Matt D
On 06/24/2013 05:57 PM, Dave Angel wrote: > On 06/24/2013 05:39 PM, Matt D wrote: >> >>> But what he's doing has nothing to do with logging. He's just using >>> that word. >>> >>> >> Right, I'm not doing a debugging thing. Just trying to create a log of >> data that has been passed into the displ

Re: [Tutor] Need help appending data to a logfile

2013-06-24 Thread Dave Angel
On 06/24/2013 05:39 PM, Matt D wrote: But what he's doing has nothing to do with logging. He's just using that word. Right, I'm not doing a debugging thing. Just trying to create a log of data that has been passed into the display of this program. Since I started trying to use the array t

Re: [Tutor] Need help appending data to a logfile

2013-06-23 Thread Dave Angel
On 06/17/2013 02:20 PM, Lukáš Němec wrote: Or even better, use python moto, dont re-invent the wheel, so use built in library logging, read the docs for it, or if you want, I can send you some examples how to work it, it takes some time to figure out properly... But what he's doing has

Re: [Tutor] Need help appending data to a logfile

2013-06-23 Thread Lukáš Němec
Dne 17. 6. 2013 20:17, Dave Angel napsal(a): On 06/17/2013 01:36 PM, Matt D wrote: Hey, I wrote some simple code to write data to a logfile and it works pretty well (thanks guys). Now my problem is that every time i run the program the old logfile.txt is overwritten. I need to be able to stop

Re: [Tutor] Need help appending data to a logfile

2013-06-19 Thread Prasad, Ramit
Peter Otten wrote: > Matt D wrote: > > > Hey, > > I wrote some simple code to write data to a logfile and it works pretty > > well (thanks guys). Now my problem is that every time i run the program > > the old logfile.txt is overwritten. > > The help() function in the interactive interpreter is

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Jim Mooney
On 17 June 2013 17:57, Dave Angel wrote: >> Well, although I would like to see my name in lights, I didn't >> discover it, Dave did, so that would be dishonest ;') >> > > http://bugs.python.org/issue18249 > filed at 8:55 pm Looks like you've got a quibble on that. But the point is, it doesn't fu

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread eryksun
On Mon, Jun 17, 2013 at 5:43 PM, Dave Angel wrote: > But in 3.3, it says: > Help on built-in function close: > > close(...) > > with no more explanation. The category "built-in function" here doesn't mean it's in the builtins namespace. It means it's a function or method from an extension module

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Dave Angel
On 06/17/2013 08:07 PM, Jim Mooney wrote: On 17 June 2013 16:04, Mark Lawrence wrote: You now have an opportunity to expand your knowledge of the Python infrastructure by raising your first bug report to get this fixed. I look forward to seeing your effort on the bug tracker mailing list.

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Jim Mooney
On 17 June 2013 16:04, Mark Lawrence wrote: > > You now have an opportunity to expand your knowledge of the Python > infrastructure by raising your first bug report to get this fixed. I look > forward to seeing your effort on the bug tracker mailing list. Well, although I would like to see my n

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Mark Lawrence
On 17/06/2013 23:39, Jim Mooney wrote: But in 3.3, it says: Help on built-in function close: close(...) with no more explanation. Hmm, I thought close in 3.3 was a method of the file handle, not a builtin function. Have I missed something? I assume all builtin functions do not need an object

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Jim Mooney
> But in 3.3, it says: > Help on built-in function close: > > close(...) > > with no more explanation. Hmm, I thought close in 3.3 was a method of the file handle, not a builtin function. Have I missed something? I assume all builtin functions do not need an object dot prefix, and close needs the

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Dave Angel
On 06/17/2013 05:17 PM, Jim Mooney wrote: On 17 June 2013 11:30, Peter Otten <__pete...@web.de> wrote: The help() function in the interactive interpreter is a good tool hunt for help on features of functions and classes. For example: I tripped on Python help a couple of times, since I'm used

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Jim Mooney
On 17 June 2013 11:30, Peter Otten <__pete...@web.de> wrote: > The help() function in the interactive interpreter is a good tool hunt for > help on features of functions and classes. For example: I tripped on Python help a couple of times, since I'm used to easy-living GUI help, so here is a bit

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Peter Otten
Matt D wrote: > Hey, > I wrote some simple code to write data to a logfile and it works pretty > well (thanks guys). Now my problem is that every time i run the program > the old logfile.txt is overwritten. The help() function in the interactive interpreter is a good tool hunt for help on fea

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Dave Angel
On 06/17/2013 01:36 PM, Matt D wrote: Hey, I wrote some simple code to write data to a logfile and it works pretty well (thanks guys). Now my problem is that every time i run the program the old logfile.txt is overwritten. I need to be able to stop and start the program without overwriting, or