Re: python read line by line and keep indent

2020-04-18 Thread Souvik Dutta
Oh! Sorry I didn't get that earlier. 😛 On Sat, 18 Apr, 2020, 9:10 pm MRAB, wrote: > On 2020-04-18 08:59, Souvik Dutta wrote: > > Okay so I was not able to say properly. You are indeed doing the same > thing > > that you were doing i.e. writting the modified data just, that now you > > don't need

Re: python read line by line and keep indent

2020-04-18 Thread MRAB
On 2020-04-18 08:59, Souvik Dutta wrote: Okay so I was not able to say properly. You are indeed doing the same thing that you were doing i.e. writting the modified data just, that now you don't need to close you if file before doing any writting stuff. That is there is a one line deduction from t

Re: python read line by line and keep indent

2020-04-18 Thread Souvik Dutta
Okay so I was not able to say properly. You are indeed doing the same thing that you were doing i.e. writting the modified data just, that now you don't need to close you if file before doing any writting stuff. That is there is a one line deduction from the whole code. Souvik flutter dev On Sat,

Re: python read line by line and keep indent

2020-04-18 Thread Peter Otten
Souvik Dutta wrote: > You can actually read and write in a file simultaneously. Just replace "r" > with "w+" if the file has not been previously made or use "r+" is the file > has already been made. Good advice for those who like to butcher their data ;) Seriously, writing modified data into a n

Re: python read line by line and keep indent

2020-04-17 Thread Souvik Dutta
You can actually read and write in a file simultaneously. Just replace "r" with "w+" if the file has not been previously made or use "r+" is the file has already been made. Souvik flutter dev On Sat, Apr 18, 2020, 4:45 AM wrote: > Hi; > > I am reading a Python file and find an specific line, re

Re: python read line by line and keep indent

2020-04-17 Thread DL Neil via Python-list
On 18/04/20 11:10 AM, hnasr9...@gmail.com wrote: I am reading a Python file and find an specific line, replace a text and then write back to the file. When I check back the file, I am getting indent error. How to fix this issue. Please make it easier for us (volunteers giving-up our free ti

Re: python read line by line and keep indent

2020-04-17 Thread Greg Ewing
On 18/04/20 11:10 am, hnasr9...@gmail.com wrote: Hi; I am reading a Python file and find an specific line, replace a text and then write back to the file. When I check back the file, I am getting indent error. It looks like your script is stripping out all the indentation when it writes the

python read line by line and keep indent

2020-04-17 Thread hnasr9999
Hi; I am reading a Python file and find an specific line, replace a text and then write back to the file. When I check back the file, I am getting indent error. How to fix this issue. reading_file = open("myfile.py", "r") new_file_content = "" for line in reading_file: