On Sun, 01 Nov 2009 10:44:45 +0100, Alf P. Steinbach wrote:
> Could you post (copy and paste) the code, and description of results?
Using Python 2.6 under Linux (Fedora 7):
>>> f = open('garbage', 'r') # prove the file doesn't exist
Traceback (most recent call last):
File "", line 1, in
IOEr
Gertjan Klein wrote:
> Alf P. Steinbach wrote:
>
>> So with 'w+' the only way to get garbage is if 'read' reads beyond the end
>> of
>> file, or 'open' doesn't conform to the documentation.
>
> It does read beyond the end of file. This is perhaps the way the
> underlying C library works, but it
Alf P. Steinbach wrote:
>* Gertjan Klein:
>> I reproduced (with Python 2.5.2 on WinXP) the code the OP wrote after
>> creating an empty (0-byte) test file; after the write() the read()
>> returns random garbage. I can't imagine why anyone would want that
>> behaviour. The file grew to be 4099 byte
* Gertjan Klein:
Alf P. Steinbach wrote:
So with 'w+' the only way to get garbage is if 'read' reads beyond the end of
file, or 'open' doesn't conform to the documentation.
It does read beyond the end of file. This is perhaps the way the
underlying C library works, but it looks like an "unexp
Alf P. Steinbach wrote:
>So with 'w+' the only way to get garbage is if 'read' reads beyond the end of
>file, or 'open' doesn't conform to the documentation.
It does read beyond the end of file. This is perhaps the way the
underlying C library works, but it looks like an "unexpected feature"
(re
On Oct 31, 3:11 pm, Terry Reedy wrote:
Great, thanks.
> Zeynel wrote:
> > On Oct 31, 10:40 am, "Alf P. Steinbach" wrote:
> > Thanks! This works. But I need to close the file before read and open
> > it again with "r", otherwise I get the garbage again. Can you give me
> > the link where you got
Zeynel wrote:
On Oct 31, 10:40 am, "Alf P. Steinbach" wrote:
Thanks! This works. But I need to close the file before read and open
it again with "r", otherwise I get the garbage again. Can you give me
the link where you got this in documentation:
"The mode 'w+' opens and truncates the file to 0
On Oct 31, 10:40 am, "Alf P. Steinbach" wrote:
Thanks! This works. But I need to close the file before read and open
it again with "r", otherwise I get the garbage again. Can you give me
the link where you got this in documentation:
"The mode 'w+' opens and truncates the file to 0 bytes, while 'r
Zeynel wrote:
On Oct 31, 9:55 am, "Alf P. Steinbach" wrote:
* Zeynel:
On Oct 31, 9:23 am, "Alf P. Steinbach" wrote:
* Zeynel:
Hello,
I've been studying the official tutorial, so far it's been fun, but
today I ran into a problem with the write(). So, I open the f
* Zeynel:
On Oct 31, 9:55 am, "Alf P. Steinbach" wrote:
* Zeynel:
On Oct 31, 9:23 am, "Alf P. Steinbach" wrote:
* Zeynel:
Hello,
I've been studying the official tutorial, so far it's been fun, but
today I ran into a problem with the write(). So, I open the file pw
and write "hello" and
On Oct 31, 9:55 am, "Alf P. Steinbach" wrote:
> * Zeynel:
>
>
>
>
>
> > On Oct 31, 9:23 am, "Alf P. Steinbach" wrote:
> >> * Zeynel:
>
> >>> Hello,
> >>> I've been studying the official tutorial, so far it's been fun, but
> >>> today I ran into a problem with the write(). So, I open the file pw
>
* Zeynel:
On Oct 31, 9:23 am, "Alf P. Steinbach" wrote:
* Zeynel:
Hello,
I've been studying the official tutorial, so far it's been fun, but
today I ran into a problem with the write(). So, I open the file pw
and write "hello" and read:
f = open("pw", "r+")
f.write("hello")
f.read()
But r
On Oct 31, 9:23 am, "Alf P. Steinbach" wrote:
> * Zeynel:
>
>
>
>
>
> > Hello,
>
> > I've been studying the official tutorial, so far it's been fun, but
> > today I ran into a problem with the write(). So, I open the file pw
> > and write "hello" and read:
>
> > f = open("pw", "r+")
> > f.write("h
* Zeynel:
Hello,
I've been studying the official tutorial, so far it's been fun, but
today I ran into a problem with the write(). So, I open the file pw
and write "hello" and read:
f = open("pw", "r+")
f.write("hello")
f.read()
But read() returns a bunch of what looks like meta code:
"ont': 1
14 matches
Mail list logo