On May 10, 7:11 pm, Jon Pentland <[EMAIL PROTECTED]> wrote:
> I don't really see the use for being able to do that. Have you tried
>
Well, I think I found a reason and it probably happens quite a bit.
I open the file and read it into a list. I pop some elements from the
list for processing and th
En Thu, 10 May 2007 21:11:16 -0300, Jon Pentland <[EMAIL PROTECTED]>
escribió:
> I don't really see the use for being able to do that. Have you tried
> doing it with the 'app' mode?, But I am guessing that it is just an
> advanced mode spawned from 'w'. So, no, I don't think you can do this.
In
I don't really see the use for being able to do that. Have you tried
doing it with the 'app' mode?, But I am guessing that it is just an
advanced mode spawned from 'w'. So, no, I don't think you can do this.
--
http://mail.python.org/mailman/listinfo/python-list
> After reading a file is it possible to write to it without first
> closing it? I tried opening with 'rw' access and re-winding. This does
> not seem to work unless comments are removed.
>
>
> Also, does close force a flush?
>
> Thanks,
>
> jh
>
> #~~
>
> f = open('c:\\
After reading a file is it possible to write to it without first
closing it? I tried opening with 'rw' access and re-winding. This does
not seem to work unless comments are removed.
Also, does close force a flush?
Thanks,
jh
#~~
f = open('c:\\tempMaxq\\incidents.tx
On 2007-01-05 03:46, tubby wrote:
> Is this the safest, most portable way to open files on any platform:
>
> fp = open(file_name, 'rb')
> fp.close()
>
> I understand that doing the following on Windows to a binary file (a
> jpeg or exe files for example) can cause file corruption, is that correct?
At Thursday 4/1/2007 23:46, tubby wrote:
I understand that doing the following on Windows to a binary file (a
jpeg or exe files for example) can cause file corruption, is that correct?
fp = open(file_name, 'r')
fp.close()
How can a simple open in read mode corrupt data???
You can't corrupt *
Does a py script written to open and read binary files on Windows affect
files on a Linux or Mac machine in a negative way? My concern is
portability and safety. I want scripts written within Windows to work
equally well on Linux and Mac computers.
Is this the safest, most portable way to open
erikcw wrote:
> To make it write over the data, I ended up adding, which seems to work
> fine.
>
> f = open('_i_defines.php', 'w+')
that doesn't work; you need to use "r+" if you want to keep the original
contents.
"w+" means truncate first, update then:
>>> f = open("foo.txt", "r")
>>> f.r
"erikcw" <[EMAIL PROTECTED]> wrote:
8<
> #loop through patterns list and find/replace data
> for o, r in patterns:
> data = data.replace(o, r)
> print "Replaced %s with %s" % (o, r)
> f.write(data)
> f.close()
>
> This results in an empty file. All of the
Don't do that. Do something like renaming the old file
to .bak (or .aside or something) and then create the entire file
by opening it with 'w'.
-Larry
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 3, 4:00 pm, "martdi" <[EMAIL PROTECTED]> wrote:
> > At first I was convinced that "w+" was the tool for the job. But now
> > I'm finding that the contents of the file are deleted (so I can't read
> > the data in).Possible File Modes:
&
> At first I was convinced that "w+" was the tool for the job. But now
> I'm finding that the contents of the file are deleted (so I can't read
> the data in).
Possible File Modes:
a : Append -- Add data at the end of the file
r : Read -- Read from the file
w : w
Hi all,
I've created a script that reads in a file, replaces some data (regex),
then writes the new data back to the file.
At first I was convinced that "w+" was the tool for the job. But now
I'm finding that the contents of the file are deleted (so I can't read
the data in).
f = open('_i_defin
14 matches
Mail list logo