On Sat, 30 Apr 2016 06:26 am, boB Stepp wrote:
> On Mon, Apr 25, 2016 at 8:51 PM, Steven D'Aprano
> wrote:
>
>> See here for the *start* of a more professional approach:
>>
>>
http://code.activestate.com/recipes/579097-safely-and-atomically-write-to-a-file/
>
> What else would I need to know/co
On Mon, Apr 25, 2016 at 8:51 PM, Steven D'Aprano wrote:
> See here for the *start* of a more professional approach:
>
> http://code.activestate.com/recipes/579097-safely-and-atomically-write-to-a-file/
What else would I need to know/consider in order to have a *complete*
professional approach?
On Tue, Apr 26, 2016, at 07:56 PM, Seymore4Head wrote:
> On Tue, 26 Apr 2016 11:53:57 +1000, Steven D'Aprano
> wrote:
>
> >On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote:
> >
> >> BTW I was trying to use a line like yours that used an output file
> >> that didn't exist and was getting an error.
On Wed, Apr 27, 2016 at 12:56 PM, Seymore4Head
wrote:
> On Tue, 26 Apr 2016 11:53:57 +1000, Steven D'Aprano
> wrote:
>
>>On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote:
>>
>>> BTW I was trying to use a line like yours that used an output file
>>> that didn't exist and was getting an error. I a
On Tue, 26 Apr 2016 19:16:56 +0100, Michael
wrote:
>If you want to read an entire file, append a space and asterisk and write it
>to another file, this is the code you need:
>
>infile = open('win.txt', 'r')
>text = f.read()
>infile.close()
>text += " *"
>outfile = open('outfile.txt', 'w')
>outfi
On Tue, 26 Apr 2016 11:53:57 +1000, Steven D'Aprano
wrote:
>On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote:
>
>> BTW I was trying to use a line like yours that used an output file
>> that didn't exist and was getting an error. I assume that import os
>> fixes that.
>
>
>Why would you assume th
If you want to read an entire file, append a space and asterisk and write it to
another file, this is the code you need:
infile = open('win.txt', 'r')
text = f.read()
infile.close()
text += " *"
outfile = open('outfile.txt', 'w')
outfile.write(text)
outfile.close()
If, on the other hand, you wis
Steven D'Aprano wrote:
(Possible a few very old operating systems on
supercomputers from the 1970s or 80s may have supported inserting... I seem
to recall that VMS may have allowed that... but don't quote me.)
I wouldn't be surprised if VMS provided some sort of indexed
random-access file struc
On Tue, 26 Apr 2016 11:51:23 +1000, Steven D'Aprano wrote:
> ... (Possible a few very old operating systems on supercomputers from
> the 1970s or 80s may have supported inserting... I seem to recall that
> VMS may have allowed that... but don't quote me.)
Some [non-supercomputer] OSes/filesystems
On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote:
> BTW I was trying to use a line like yours that used an output file
> that didn't exist and was getting an error. I assume that import os
> fixes that.
Why would you assume that?
"Doctor, I have a problem with my arm, but I won't tell you wha
On Tue, 26 Apr 2016 05:00 am, Seymore4Head wrote:
> I was reading that. I have read it before. I don't use python enough
> to even remember the simple stuff. Then when I try to use if for
> something simple I forget how.
It is perfectly fine to forget things that you read weeks or months befor
On Tue, Apr 26, 2016 at 7:26 AM, John Gordon wrote:
> It's much easier to create a new file and then rename it afterwards,
> instead of rewriting the original file.
And more importantly, it's safer. If anything happens to your process
while it's doing its work, you'll have a junk file sitting aro
On Mon, 25 Apr 2016 21:26:34 + (UTC), John Gordon
wrote:
>In <27nshbp40p1llr231dqm31p754tvurk...@4ax.com> Seymore4Head
> writes:
>
>> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head
>> wrote:
>
>> I am going to forget using a directory path.
>> I would like to take the file win.txt and app
Random832 wrote:
> On Mon, Apr 25, 2016, at 16:15, Seymore4Head wrote:
>> Thanks for the tip.
>>
>> Still broke. :(
>>
>> f = open('wout.txt', 'r+')
>> for line in f:
>> if line=="":
>> exit
>> line=line[:-1]
>> line=line+" *"
>> f.write(line)
>> print line
>> f.clos
In <27nshbp40p1llr231dqm31p754tvurk...@4ax.com> Seymore4Head
writes:
> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head
> wrote:
> I am going to forget using a directory path.
> I would like to take the file win.txt and append a space and the *
> symbol.
> f = open('win.txt', 'r+')
> for line
removing some other character. It's safer to use
>line.rstrip("\n").
>
>> -Original Message-
>> From: Python-list
>> [mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf
>> Of Seymore4Head
>> Sent: 25 April 2016 20:01
On Mon, Apr 25, 2016, at 16:15, Seymore4Head wrote:
> Thanks for the tip.
>
> Still broke. :(
>
> f = open('wout.txt', 'r+')
> for line in f:
> if line=="":
> exit
> line=line[:-1]
> line=line+" *"
> f.write(line)
> print line
> f.close()
Your problem is that after y
e beginning and the end of the string (default whitespace
>characters).
>
>Use to remove return carriage--> line[:-1]
>
>-Original Message-
>From: Python-list
>[mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf Of
>Seymore4Head
>Sent: 25
ine ending, so
line[:-1] could be removing some other character. It's safer to use
line.rstrip("\n").
-Original Message-
From: Python-list
[mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf Of
Seymore4Head
Sent: 25 April 2016 20:01
To: python-list@python
Seymore4Head wrote:
> On Mon, 25 Apr 2016 18:24:02 - (UTC), Rob Gaddi
> wrote:
>
>>Seymore4Head wrote:
>>
>>> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head
>>> wrote:
>>>
>>> I am going to forget using a directory path.
>>> I would like to take the file win.txt and append a space and the
ist
[mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf Of
Seymore4Head
Sent: 25 April 2016 20:01
To: python-list@python.org
Subject: Re: Python path and append
On Mon, 25 Apr 2016 18:24:02 - (UTC), Rob Gaddi
wrote:
>Seymore4Head wrote:
>
>> On Tue, 19 Apr 2016
On Mon, 25 Apr 2016 18:24:02 - (UTC), Rob Gaddi
wrote:
>Seymore4Head wrote:
>
>> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head
>> wrote:
>>
>> I am going to forget using a directory path.
>> I would like to take the file win.txt and append a space and the *
>> symbol.
>>
>> f = open('win.
Seymore4Head wrote:
> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head
> wrote:
>
> I am going to forget using a directory path.
> I would like to take the file win.txt and append a space and the *
> symbol.
>
> f = open('win.txt', 'r+')
> for line in f:
> f.read(line)
> f.write(line+" *"
On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head
wrote:
I am going to forget using a directory path.
I would like to take the file win.txt and append a space and the *
symbol.
f = open('win.txt', 'r+')
for line in f:
f.read(line)
f.write(line+" *")
This doesn't work. Would someone fix
On 2016-04-19 23:38, Chris Angelico wrote:
On Wed, Apr 20, 2016 at 8:29 AM, Seymore4Head
wrote:
handle = open("\\Winmx\New$\q.txt")
for line in handle:
line=line.strip()
print line
Traceback (most recent call last):
File "\\Winmx\New$\add viewed.py", line 2, in
handle = open("
On Wed, Apr 20, 2016 at 8:29 AM, Seymore4Head
wrote:
>
> handle = open("\\Winmx\New$\q.txt")
> for line in handle:
> line=line.strip()
> print line
>
>
> Traceback (most recent call last):
> File "\\Winmx\New$\add viewed.py", line 2, in
> handle = open("\\Winmx\New$\q.txt")
> IOErro
26 matches
Mail list logo