Re: Live Write to File with Code That is Reading File and Writing to Serial Port

2020-10-28 Thread Terry Reedy
On 10/28/2020 8:49 AM, ktkelly_1 wrote: Currently have a code that takes in a .txt file and submits commands to the serial. Then it reads the reply from the serial port and writes it to a hardcoded .txt file. The problem is it doesn't save it live and so if I need to stop the code for any reaso

Re: Live Write to File with Code That is Reading File and Writing to Serial Port

2020-10-28 Thread Karen Shaeffer via Python-list
> On Oct 28, 2020, at 5:49 AM, ktkelly_1 wrote: > > Currently have a code that takes in a .txt file and submits commands to the > serial. Then it reads the reply from the serial port and writes it to a > hardcoded .txt file. The problem is it doesn't save it live and so if I need > to stop th

Live Write to File with Code That is Reading File and Writing to Serial Port

2020-10-28 Thread ktkelly_1
Currently have a code that takes in a .txt file and submits commands to the serial. Then it reads the reply from the serial port and writes it to a hardcoded .txt file. The problem is it doesn't save it live and so if I need to stop the code for any reason, I can't gather current data and the te

Re: write to file

2018-05-06 Thread Sharan Basappa
On Sunday, 6 May 2018 10:48:12 UTC+5:30, Chris Angelico wrote: > On Sun, May 6, 2018 at 3:10 PM, Sharan Basappa > wrote: > > On Saturday, 5 May 2018 21:47:33 UTC+5:30, Steven D'Aprano wrote: > >> On Sat, 05 May 2018 08:45:39 -0700, Sharan Basappa wrote: > >> > >> > Thanks a lot. I have actually

Re: write to file

2018-05-05 Thread Chris Angelico
On Sun, May 6, 2018 at 3:10 PM, Sharan Basappa wrote: > On Saturday, 5 May 2018 21:47:33 UTC+5:30, Steven D'Aprano wrote: >> On Sat, 05 May 2018 08:45:39 -0700, Sharan Basappa wrote: >> >> > Thanks a lot. I have actually tried print with file handle as a >> > parameter (the last option). I see th

Re: write to file

2018-05-05 Thread Sharan Basappa
On Saturday, 5 May 2018 21:47:33 UTC+5:30, Steven D'Aprano wrote: > On Sat, 05 May 2018 08:45:39 -0700, Sharan Basappa wrote: > > > Thanks a lot. I have actually tried print with file handle as a > > parameter (the last option). I see that the file is created but nothing > > is logged. > > That

Re: write to file

2018-05-05 Thread Sharan Basappa
On Saturday, 5 May 2018 22:05:53 UTC+5:30, Mark Lawrence wrote: > On 05/05/18 12:25, Sharan Basappa wrote: > > In my program, I have print statements for debugging. > > However, these are cluttering the display. So, I am trying to save > > these to a file but somehow I cant seem to get it correct.

Re: write to file

2018-05-05 Thread Mark Lawrence
On 05/05/18 12:25, Sharan Basappa wrote: In my program, I have print statements for debugging. However, these are cluttering the display. So, I am trying to save these to a file but somehow I cant seem to get it correct. Use the logging module https://docs.python.org/3/library/logging.html for

Re: write to file

2018-05-05 Thread Steven D'Aprano
On Sat, 05 May 2018 08:45:39 -0700, Sharan Basappa wrote: > Thanks a lot. I have actually tried print with file handle as a > parameter (the last option). I see that the file is created but nothing > is logged. That could be a file buffer issue. Nothing will actually be written to the disk until

Re: write to file

2018-05-05 Thread Sharan Basappa
On Saturday, 5 May 2018 19:00:12 UTC+5:30, Steven D'Aprano wrote: > On Sat, 05 May 2018 04:25:50 -0700, Sharan Basappa wrote: > > > In my program, I have print statements for debugging. However, these are > > cluttering the display. So, I am trying to save these to a file but > > somehow I cant s

Re: write to file

2018-05-05 Thread Steven D'Aprano
On Sat, 05 May 2018 04:25:50 -0700, Sharan Basappa wrote: > In my program, I have print statements for debugging. However, these are > cluttering the display. So, I am trying to save these to a file but > somehow I cant seem to get it correct. There are lots of way to solve this problem. The bes

write to file

2018-05-05 Thread Sharan Basappa
In my program, I have print statements for debugging. However, these are cluttering the display. So, I am trying to save these to a file but somehow I cant seem to get it correct. For example, the following are the print statement in my program: print("target_names\n",target_names) To print to a

Re: Python Fails to Write to File

2014-06-19 Thread Mark Lawrence
On 19/06/2014 08:54, cutey Love wrote: Thank you very much, that fixed it. What do you not understand about top posting and using google groups? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free f

Re: Python Fails to Write to File

2014-06-19 Thread cutey Love
Thank you very much, that fixed it. On Thursday, June 19, 2014 12:03:43 AM UTC+1, cutey Love wrote: > I'm trying to write data to a text file > > > > But I'm getting the error: > > > > TypeError: invalid file: <_io.TextIOWrapper > > > > Code is > > > > def saveFile(): > > file_p

Re: Python Fails to Write to File

2014-06-18 Thread Paul McNett
On 6/18/14, 4:03 PM, cutey Love wrote: I'm trying to write data to a text file But I'm getting the error: TypeError: invalid file: <_io.TextIOWrapper Always better to err on posting too much context (the entire traceback) than too little. Code is def saveFile(): file_path = filedia

Re: Python Fails to Write to File

2014-06-18 Thread Ian Kelly
On Wed, Jun 18, 2014 at 5:03 PM, cutey Love wrote: > I'm trying to write data to a text file > > But I'm getting the error: > > TypeError: invalid file: <_io.TextIOWrapper Post the full traceback. By posting only the error message you're removing useful information. -- https://mail.python.org/m

Python Fails to Write to File

2014-06-18 Thread cutey Love
I'm trying to write data to a text file But I'm getting the error: TypeError: invalid file: <_io.TextIOWrapper Code is def saveFile(): file_path = filedialog.asksaveasfile(mode='w', filetypes=[('text files', '.txt')], defaultextension=".txt") fo = open(file_path, 'w') for e

Re: Write to file and see content on screen

2008-06-10 Thread MRAB
On Jun 10, 2:01 am, [EMAIL PROTECTED] wrote: > Hello all, > > New user to python. I can write to a file, however, I would like to > do both...whatever I do on the screen, I'd like to write it to a file. > > any pointers on where I can find this info. > > thanks, Something like this, perhaps? cl

Re: Write to file and see content on screen

2008-06-09 Thread Timothy Grant
On Mon, Jun 9, 2008 at 6:01 PM, <[EMAIL PROTECTED]> wrote: > Hello all, > > New user to python. I can write to a file, however, I would like to > do both...whatever I do on the screen, I'd like to write it to a file. > > any pointers on where I can find this info. > > thanks, > This code has on

Re: Write to file and see content on screen

2008-06-09 Thread CM
On Jun 9, 9:01 pm, [EMAIL PROTECTED] wrote: > Hello all, > > New user to python. I can write to a file, however, I would like to > do both...whatever I do on the screen, I'd like to write it to a file. > > any pointers on where I can find this info. > > thanks, There is probably some smart way t

Write to file and see content on screen

2008-06-09 Thread lamarts
Hello all, New user to python. I can write to a file, however, I would like to do both...whatever I do on the screen, I'd like to write it to a file. any pointers on where I can find this info. thanks, -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie write to file question

2005-12-04 Thread Scott David Daniels
ProvoWallis wrote: ... > for root, dirs, files in os.walk(setpath): > fname = files > for fname in files: > inputFile = file(os.path.join(root,fname), 'r') > while 1: >lines = inputFile.readlines(1) >if not lines: >

Re: newbie write to file question

2005-12-04 Thread Rob E
> I'm not sure what I'm > missing so I'd appreciate some advice. You question is pretty general and I'm not going to go over this in any great detail, but I will make a few comments. * In your if section use if ... else constructs not all the strange if and then not if blocks. Also get rid

newbie write to file question

2005-12-03 Thread ProvoWallis
Hi, I'm trying to create a script that will search an SGML file for the numbers and titles of the hierarchical elements (section level headings) and create a dictionary with the section number as the key and the title as the value. I've managed to make some progress but I'd like to get some gener

Re: cannot write to file after close()

2005-09-26 Thread Reinhold Birkenfeld
Rainer Hubovsky wrote: > Thank you Reinhold, that was the solution. But just because I am curious: > what is this statement without the parentheses? After all it is a valid > statement... > > Rainer > > > In article <[EMAIL PROTECTED]>, Reinhold Birkenfeld wrote: >> Is the above exactly your c

Re: cannot write to file after close()

2005-09-25 Thread Fredrik Lundh
Rainer Hubovsky wrote: > Thank you Reinhold, that was the solution. But just because I am curious: > what is this statement without the parentheses? After all it is a valid > statement... it's an expression that fetches the "close" method object, and throws it away. to see what it evaluates to,

Re: cannot write to file after close()

2005-09-25 Thread Rainer Hubovsky
Thank you Reinhold, that was the solution. But just because I am curious: what is this statement without the parentheses? After all it is a valid statement... Rainer In article <[EMAIL PROTECTED]>, Reinhold Birkenfeld wrote: > Is the above exactly your code? If yes, it should be > > f.close()

Re: cannot write to file after close()

2005-09-25 Thread Reinhold Birkenfeld
Rainer Hubovsky wrote: > Hello Python-Gurus, > > == > f = open(LOGFILE,'w') > f.write(time + '\n') > f.close > > command = 'ping -n 20' + target + '>>' + LOGFILE > system(command) > == > > produces an error saying that a file cannot be accessed bec

cannot write to file after close()

2005-09-25 Thread Rainer Hubovsky
Hello Python-Gurus, == f = open(LOGFILE,'w') f.write(time + '\n') f.close command = 'ping -n 20' + target + '>>' + LOGFILE system(command) == produces an error saying that a file cannot be accessed because it is used by another process. I asume it