On 2010-10-16, Steven D'Aprano wrote:
> On Fri, 15 Oct 2010 20:07:37 +, Grant Edwards wrote:
>
>> Nor I, which is why I was confused by the statement that in the "Unix
>> world" a lot of programs misbehaved when presented with files whose
>> names contained a null byte.
>
> That's not what I s
On Fri, 15 Oct 2010 20:07:37 +, Grant Edwards wrote:
> Nor I, which is why I was confused by the statement that in the "Unix
> world" a lot of programs misbehaved when presented with files whose
> names contained a null byte.
That's not what I said. I said, TRY to create a file with a null by
On 2010-10-15, Martin Gregorie wrote:
> On Fri, 15 Oct 2010 19:59:13 +, Grant Edwards wrote:
>
>>
>> We're talking about Unix.
>> We're not talking about CP/M, DOS, RSX-11m, Apple-SOS, etc.
>
> That's just your assumption.
If you go back and look at my original posting in this thread, here's
On Fri, 15 Oct 2010 19:59:13 +, Grant Edwards wrote:
>
> We're talking about Unix.
> We're not talking about CP/M, DOS, RSX-11m, Apple-SOS, etc.
>
That's just your assumption. Track back up the thread and you'll see that
the OP didn't mention an OS. He merely said that he was using zlib, and
On 2010-10-15, Chris Torek wrote:
>>> On 2010-10-15, Grant Edwards wrote:
How do you create a [Unix] file with a name that contains a NULL byte?
>
>>On 2010-10-15, Seebs wrote:
>>> So far as I know, in canonical Unix, you don't -- the syscalls all work
>>> with something like C strings unde
On 2010-10-15, Seebs wrote:
> On 2010-10-15, Grant Edwards wrote:
>> Yes, all of the Unix syscalls use NULL-terminated path parameters
>> (AKA "C strings"). What I don't know is whether the underlying
>> filesystem code also uses NULL-terminated strings for filenames or if
>> they have explicit
On 2010-10-15, Martin Gregorie wrote:
>> On 2010-10-15, Martin Gregorie wrote:
>>> On Fri, 15 Oct 2010 17:02:07 +, Grant Edwards wrote:
On 2010-10-15, Steven D'Aprano :
> In the Unix world, which includes OS X, text tools tend to have
> difficulty with tabs. Or try naming a
>> On 2010-10-15, Grant Edwards wrote:
>>> How do you create a [Unix] file with a name that contains a NULL byte?
>On 2010-10-15, Seebs wrote:
>> So far as I know, in canonical Unix, you don't -- the syscalls all work
>> with something like C strings under the hood, meaning that no matter what
>
On 2010-10-15, Grant Edwards wrote:
> Yes, all of the Unix syscalls use NULL-terminated path parameters (AKA
> "C strings"). What I don't know is whether the underlying filesystem
> code also uses NULL-terminated strings for filenames or if they have
> explicit lengths. If the latter, there migh
On Fri, 15 Oct 2010 18:14:13 +, Grant Edwards wrote:
> On 2010-10-15, Martin Gregorie wrote:
>> On Fri, 15 Oct 2010 17:02:07 +, Grant Edwards wrote:
>>
>>> On 2010-10-15, Steven D'Aprano
>>> wrote:
>>>
In the Unix world, which includes OS X, text tools tend to have
difficulty
On 2010-10-15, Seebs wrote:
> On 2010-10-15, Grant Edwards wrote:
>> On 2010-10-15, Steven D'Aprano wrote:
>>> In the Unix world, which includes OS X, text tools tend to have
>>> difficulty with tabs. Or try naming a file with a newline or carriage
>>> return in the file name, or a NULL byte.
>
On 2010-10-15, Grant Edwards wrote:
> On 2010-10-15, Steven D'Aprano wrote:
>> In the Unix world, which includes OS X, text tools tend to have
>> difficulty with tabs. Or try naming a file with a newline or carriage
>> return in the file name, or a NULL byte.
> How do you create a file with a n
On 2010-10-15, Martin Gregorie wrote:
> On Fri, 15 Oct 2010 17:02:07 +, Grant Edwards wrote:
>
>> On 2010-10-15, Steven D'Aprano
>> wrote:
>>
>>> In the Unix world, which includes OS X, text tools tend to have
>>> difficulty with tabs. Or try naming a file with a newline or carriage
>>> retu
On Fri, 15 Oct 2010 17:02:07 +, Grant Edwards wrote:
> On 2010-10-15, Steven D'Aprano
> wrote:
>
>> In the Unix world, which includes OS X, text tools tend to have
>> difficulty with tabs. Or try naming a file with a newline or carriage
>> return in the file name, or a NULL byte.
>
> How do
On 2010-10-15, Steven D'Aprano wrote:
> In the Unix world, which includes OS X, text tools tend to have
> difficulty with tabs. Or try naming a file with a newline or carriage
> return in the file name, or a NULL byte.
How do you create a file with a name that contains a NULL byte?
--
Grant E
On Oct 14, 10:30 pm, Lawrence D'Oliveiro wrote:
> In message , Rhodri James wrote:
>
> > ... frankly putting arbitrary binary into a literal string is rather
> > asking for something like this to come and bite you.
>
> It normally works fine on sensible OSes.
Which OSes would those be? It doesn'
On Fri, 15 Oct 2010 17:30:20 +1300, Lawrence D'Oliveiro wrote:
> In message , Rhodri James wrote:
>
>> ... frankly putting arbitrary binary into a literal string is rather
>> asking for something like this to come and bite you.
>
> It normally works fine on sensible OSes.
What does it have to d
In message , Rhodri James wrote:
> ... frankly putting arbitrary binary into a literal string is rather
> asking for something like this to come and bite you.
It normally works fine on sensible OSes.
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Oct 11, 2010 at 3:59 PM, Rhodri James
wrote:
> On Mon, 11 Oct 2010 10:37:09 +0100, bussiere bussiere
> wrote:
>
>
> i've looked on the web and here but i didn't find an answer : here is my
>> code
>>
>> zlib.decompress("""
>> xワᆳヤ=ラᄇHナs~Ʀᄑç\ムîà
>> z...@ÑÁÔqÇlxÇÆïpp
>> ~ýVãì゙M6ÛÐ|ê֭ᄁᄂヤ=)}
On Mon, 11 Oct 2010 10:37:09 +0100, bussiere bussiere
wrote:
i've looked on the web and here but i didn't find an answer : here is my
code
zlib.decompress("""
xワᆳヤ=ラᄇHナs~Ʀᄑç\ムîà
z...@ÑÁÔqÇlxÇÆïpp~ývãì゙m6ÛÐ|ê֭ᄁᄂヤ=)}éÓUeö3ᄎᄌú"}ʿïÿ÷1þ8ñ́U÷ᄏñíLÒVi:`ᄈᄎL!Ê҆p6-%Fë^ヘ÷à,Q.K!ユô`ÄA!ÑêweÌ
ÊÚAロYøøÂjôóᅠÂcñ
Prasoon wrote:
I modified my code to
#Euler Totient Function
import sys
from math import sqrt
def etf(n):
i,res =2,n
while(i*i<=n):
if(n%i==0):
res-=res/i
while(n%i==0):
n/=i
i+=1
if(n>1):
res-=res/n
return res
def main():
while Tr
> You could do:
>
> while True:
> x = raw_input("Enter x=>")
> if x != "" : break # if you just press enter, raw_input returns an
> empty string
>
> Note that this still leaves out the case when you type something which
> is not a number.
> To cover this case, supposing that you need a float
On 12 Giu, 08:49, Prasoon wrote:
> On Jun 12, 11:28 am, Chris Rebert wrote:
>
>
>
>
>
> > On Thu, Jun 11, 2009 at 11:17 PM, Prasoon wrote:
> > > I am new to python
> > > I have written the following program in python.It is the solution of
> > > problem ETF in SPOJ.
>
> > > #Euler Totient
On Jun 12, 11:28 am, Chris Rebert wrote:
> On Thu, Jun 11, 2009 at 11:17 PM, Prasoon wrote:
> > I am new to python
> > I have written the following program in python.It is the solution of
> > problem ETF in SPOJ.
>
> > #Euler Totient Function
>
> > from math import sqrt
> > def etf(n):
> >
On Jun 12, 11:28 am, Chris Rebert wrote:
> On Thu, Jun 11, 2009 at 11:17 PM, Prasoon wrote:
> > I am new to python
> > I have written the following program in python.It is the solution of
> > problem ETF in SPOJ.
>
> > #Euler Totient Function
>
> > from math import sqrt
> > def etf(n):
> >
On Thu, Jun 11, 2009 at 11:17 PM, Prasoon wrote:
> I am new to python
> I have written the following program in python.It is the solution of
> problem ETF in SPOJ.
>
>
> #Euler Totient Function
>
> from math import sqrt
> def etf(n):
> i,res =2,n
> while(i*i<=n):
> if(n%i==0):
>
Thanks for the shutil.copyfileobj.
Oddly, the EOFError didnt work though.
Gabriel Genellina wrote:
En Fri, 22 Aug 2008 16:53:58 -0300, Wojtek Walczak <[EMAIL PROTECTED]> escribió:
On Fri, 22 Aug 2008 22:18:37 +0530, Anjanesh Lekshminarayanan wrote:
Im trying to download a file from a
En Fri, 22 Aug 2008 16:53:58 -0300, Wojtek Walczak <[EMAIL PROTECTED]> escribió:
> On Fri, 22 Aug 2008 22:18:37 +0530, Anjanesh Lekshminarayanan wrote:
>
>> Im trying to download a file from a server. But how do I detect EOF ?
>
> Whenever read() method returns empty string/list.
>
>
>> while f1:
>> Im trying to download a file from a server. But how do I detect EOF ?
Shouldn't this work as well?
f1 = urllib2.urlopen('ftp://username:[EMAIL PROTECTED]/data.zip')
f2 = file("data.zip", "wb")
while f1: # When to stop ?
try :
f2.write(f1.read(1024))
except EOFError :
b
On Fri, 22 Aug 2008 22:18:37 +0530, Anjanesh Lekshminarayanan wrote:
> Im trying to download a file from a server. But how do I detect EOF ?
Whenever read() method returns empty string/list.
> while f1: # When to stop ?
retval = f1.read()
if not retval:
break
f2.write(ret
On Nov 24, 12:03 am, MonkeeSage <[EMAIL PROTECTED]> wrote:
>
> class open(file):
> def __init__(self, name):
> self.size = os.stat(name).st_size
> file.__init__(self, name)
> def eof(self):
> return self.tell() == self.size
>
> f = open('tmp.py')
> print f.eof() # False
> f.read()
>
On Nov 22, 10:37 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
>
> def read(self, size=None):
> if size is None:
> val = file.read(self)
> self.eof = True
> else:
> val = file.read(self, size)
> if len(val) < size:
> self.eof = True
ZeD wrote:
> Grant Edwards wrote:
>
>> The user-defined xor is operates on "logical" boolean values.
>> The one in the operator module is a bitwise operator.
>
> def xor(a, b):
> return bool(a) ^ bool(b)
>
> seems more explicit to me.
> maybe, to make "more" explicit (too much, onestly...)
>
Grant Edwards wrote:
> The user-defined xor is operates on "logical" boolean values.
> The one in the operator module is a bitwise operator.
def xor(a, b):
return bool(a) ^ bool(b)
seems more explicit to me.
maybe, to make "more" explicit (too much, onestly...)
from operator import xor as b
On 2007-11-26, Boris Borcic <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>> def xor(a, b):
>> return a and not b or b and not a
>
>
> >>> from operator import xor
> >>> help(xor)
> Help on built-in function xor in module operator:
>
> xor(...)
> xor(a, b) -- Same as a ^ b.
Which
[EMAIL PROTECTED] wrote:
> def xor(a, b):
> return a and not b or b and not a
>>> from operator import xor
>>> help(xor)
Help on built-in function xor in module operator:
xor(...)
xor(a, b) -- Same as a ^ b.
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 23, 2:06 am, greg <[EMAIL PROTECTED]> wrote:
> There's a fair amount of overhead associated with providing
> the ability to set arbitrary attributes on an object, which
> is almost never wanted for built-in types, so it's not
> provided by default.
>
> You can easily get it if you want it by
Dennis Lee Bieber wrote:
> Pascal I/O worked with a "one element preread", where what we'd
> consider a read operation was performed by the open operation -- which
> made console I/O a royal pain
Yep. Later implementations reduced the pain somewhat by
using a "lazy" scheme which deferred the
On Nov 23, 10:43 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> This is not the same as ISO C. f.tell could be equal to
> File.size(f.path) and eof could be false. An extra read() is required.
My bad. As you might have surmised, I'm not a genius when it comes to
C. I thought that the eof f
On Nov 24, 2:24 am, MonkeeSage <[EMAIL PROTECTED]> wrote:
>
> Actually, to be a bit more technical, IO#eof acts like standard C eof
> for File objects, it only blocks / requires a previous read() on
> character devices and pipes and such. For files, it's the same as
> checking the absolute position
On Nov 23, 10:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Ruby doesn't have the good ol' eof. Good old eof tests a single flag
> and requires a pre read(). Ruby's eof blocks and does buffering (and
> this is a very strong technical statement).
Actually, to be a bit more technical, IO
On Nov 22, 1:17 pm, braver <[EMAIL PROTECTED]> wrote:
> Ruby has iterators and generators too, but it also has my good ol'
> f.eof(). I challenge the assumption here of some majectically Python-
Ruby doesn't have the good ol' eof. Good old eof tests a single flag
and requires a pre read(). Ruby'
On Nov 23, 6:56 pm, greg <[EMAIL PROTECTED]> wrote:
> By not providing an eof() function, C -- and Python -- make
> it clear that testing for eof is not a passive operation.
> It's always obvious what's going on, and it's much harder to
> make mistakes like the above.
err...C has feof() in stdio
braver wrote:
> Historically, is it possible to trace the eof-related design decision
> in stdlib?
You seem to be assuming that someone started out with a design
that included an eof() of the kind you want, and then decided
to remove it.
But I doubt that such a method was ever considered in the f
On 2007-11-23, braver <[EMAIL PROTECTED]> wrote:
> Can we say that f.eof() in fact can check for EOF right after
> we've read all characters from a file, but before a failed
> attempt to read beyond? In Python's idiom,
>
> for line lin file:
># look at a line
># we can tell eof occurs righ
On Nov 22, 8:04 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> I think Python is well rid of such a seldomly useful source of
> confusion.
So all that code folks wrote in Algol-like languages, -- e.g. this
works in Ada, --
while not End_of_File(f) loop
--
end if;
-- are confusing? Why not int
On Nov 22, 11:04 am, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> I think it's too low level, and so doesn't do what naive users
> expect. It's really only useful, even in C, as part of the
> forensic study of a stream in an error state, [...]
Indeed. I just wrote a little implementation of an IPS p
Hendrik van Rooyen wrote:
> So he can't even help himself by setting his
> own EOF attribute to False initially, and
> to True when he sees an empty string.
>
> Is there a reason for this Bondage style?
There's a fair amount of overhead associated with providing
the ability to set arbitrary attri
On 2007-11-22, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> "Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
>
Language comparisons are sometimes good. They are best when
they are free of FUD.
>>>
>>> So why Python's IO cannot yield f.eof() as easily as Ruby's can? :)
>>
>> Because that requ
Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> I don't get it, Python's files are implemented on top of stdio FILE
> objects, which do buffering and provide EOF checking (of the sort
> where you can check if a previous read hit the EOF, but still). Why
> not export that functionality?
Alexy wants to
On Nov 22, 6:40 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
> You yourself said that performance is a complaint of yours regarding Ruby, so
> why claim that Ruby's way is clearly better in a case where it causes a known
> performance hit?
See Hrvoje's remark above -- we can have EOF and e
braver <[EMAIL PROTECTED]> writes:
> On Nov 22, 6:10 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
>> Granted, they aren't part of the stdlib - but then, lots
>> of things aren't.
>
> As Hendrik noticed, I can't even add my own f.eof() if I want to
> have buffering -- is that right?
You can,
On Thu, Nov 22, 2007 at 07:17:41AM -0800, braver wrote regarding Re: eof:
>
> On Nov 22, 6:08 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
>
> > > So why Python's IO cannot yield f.eof() as easily as Ruby's can? :)
>
> > Because that
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
>>> Language comparisons are sometimes good. They are best when
>>> they are free of FUD.
>>
>> So why Python's IO cannot yield f.eof() as easily as Ruby's can? :)
>
> Because that requires buffering, something that affects speed.
I don't get it, Py
On Nov 22, 6:10 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Granted, they aren't part of the stdlib - but then, lots
> of things aren't.
As Hendrik noticed, I can't even add my own f.eof() if I want to have
buffering -- is that right? The tradeoff between speed and
convenience is somethin
On Nov 22, 6:08 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
> > So why Python's IO cannot yield f.eof() as easily as Ruby's can? :)
> Because that's not how you compare languages. You compare languages by
> stating what you are actually trying to do, and figuring out the most natural
>
braver schrieb:
> On Nov 22, 5:32 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>>> There's nothing special about Python except indentation, which
>>> gets screwed up between editors all the time. (It's much
>>> easier to flip- flop between TextMate and Emacs with Ruby than
>>> with Python, without
On Thu, Nov 22, 2007 at 06:53:59AM -0800, braver wrote regarding Re: eof:
>
> > Language comparisons are sometimes good. They are best when
> > they are free of FUD.
>
> So why Python's IO cannot yield f.eof() as easily as Ruby's can? :)
Because that's
On Nov 22, 5:32 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> > There's nothing special about Python except indentation, which
> > gets screwed up between editors all the time. (It's much
> > easier to flip- flop between TextMate and Emacs with Ruby than
> > with Python, without setting your tabs
Duncan Booth wrote:
> Nice, thank you.
Welcome.
> But why 'count(chunksize)' rather than just 'count()'?
To number the first chunk 1, etc. using count() starts with 0. Matter of taste.
> Does it make a difference anywhere? And I'd recommend using // rather than
> / otherwise it breaks if you
On 2007-11-22, braver <[EMAIL PROTECTED]> wrote:
> On Nov 22, 10:37 am, Wayne Brehaut <[EMAIL PROTECTED]> wrote:
>> As others have already pointed out, "because it's seldom
>> necessary in Python".
>
> You know what? I've read this many times, and it's a lot of
> self- congratulation. There's lot
Boris Borcic <[EMAIL PROTECTED]> wrote:
> Duncan Booth wrote:
>> import itertools
>> def chunks(f, size):
>> iterator = iter(f)
>> def onechunk(line):
>> yield line
>> for line in itertools.islice(iterator, size-1):
>> yield line
>> for line in iterator:
>>
> def chunked(chunksize,f) :
> from itertools import count,groupby
> counter=count(chunksize).next
> return groupby(f,lambda _ : counter()/chunksize)
And more to the point, no "yield" for Alexy to mock :)
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth wrote:
> import itertools
> def chunks(f, size):
> iterator = iter(f)
> def onechunk(line):
> yield line
> for line in itertools.islice(iterator, size-1):
> yield line
> for line in iterator:
> yield onechunk(line)
Quite simpler, and pro
On Nov 22, 3:26 pm, Duncan Booth <[EMAIL PROTECTED]> wrote:
> This sounds like a case for writing a generator. Try this one: [...]
Thanks, Duncan! Really cool & useful. And yield is the Ruby way,
too! (Wayne -- :P).
Cheers,
Alexy
--
http://mail.python.org/mailman/listinfo/python-list
braver <[EMAIL PROTECTED]> wrote:
> In many cases, you want to do this:
>
> for line in f:
>
> if line % 1000 == 0 or f.eof(): # eof() doesn't exist in Python
> yet!
>
>
> My control logic summarizes every 1000 lines of a file. I have to
> issue the summary after each 1000 lin
On Nov 22, 5:08 am, I V <[EMAIL PROTECTED]> wrote:
> On Wed, 21 Nov 2007 17:06:15 -0800, braver wrote:
> It looks like ruby internally buffers the stream itself, which is how
> come it can support this. According to the docs:
>
> "Note that IO#eof? reads data to a input buffer."
>
> http://www.ruby
On Nov 22, 10:37 am, Wayne Brehaut <[EMAIL PROTECTED]> wrote:
> As others have already pointed out, "because it's seldom necessary in Python".
You know what? I've read this many times, and it's a lot of self-
congratulation. There's lot of things which can be useful in Python.
This lack of EOF
"braver" <[EMAIL PROTECTED]> wrote:
> Well folks compare scripting languages all the time, and surely Ruby
> is closer to Python than C++. Since Ruby can do f.eof, which is
> easily found in its references, and Python can't, or its EOF can't
> easily be found -- the one *equivalent* to a semanti
On Wed, 21 Nov 2007 17:06:15 -0800 (PST), braver
<[EMAIL PROTECTED]> wrote:
>On Nov 22, 3:41 am, Wayne Brehaut <[EMAIL PROTECTED]> wrote:
>> If you have PythonWin 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310
>> 32 bit (Intel)] on win32.for example, using Help, Index, eof gives:
>>
8< ===
On Wed, 21 Nov 2007 15:17:14 -0800, braver wrote:
> I'd like to check, for a filehandle f, that EOF has been reached on it.
> What's the way to do it? I don't want to try/except on EOF, I want to
> check, after I read a line, that now we're in the EOF state.
Why? For some file-like objects, the
On Wed, 21 Nov 2007 17:06:15 -0800, braver wrote:
> Why do I have to count sizes of lines read and compare it to some
> filesize or do other weird tricks just to see, in a way not changing my
> input stream, whether it's at the, well, EOF?
Because you can't, generally, tell whether or not a stream
On 2007-11-21, braver <[EMAIL PROTECTED]> wrote:
> I'd like to check, for a filehandle f, that EOF has been reached on
> it. What's the way to do it? I don't want to try/except on EOF, I
> want to check, after I read a line, that now we're in the EOF state.
> In Ruby it's f.eof:
>
> In Ruby:
>>>
On Nov 22, 3:41 am, Wayne Brehaut <[EMAIL PROTECTED]> wrote:
> If you have PythonWin 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310
> 32 bit (Intel)] on win32.for example, using Help, Index, eof gives:
>
> eof
> Token used to determine end of file. This will be set to the empty
> string ('')
Hi braver,
On Wed, 21 Nov 2007 15:17:14 -0800 (PST), braver
<[EMAIL PROTECTED]> wrote:
>I'd like to check, for a filehandle f, that EOF has been reached on
>it. What's the way to do it? I don't want to try/except on EOF, I
>want to check, after I read a line, that now we're in the EOF state.
I
ash wrote:
> hi,
> when i try to unpickle a pickled file in binary format, i get this
> error:
>
> E:\mdi>test.py
> Traceback (most recent call last):
> File "E:\mdi\qp.py", line 458, in OnReadButton
> data=p.load(file("ques.dat","r"))
> EOFError
>
> what is the reason? how do i overcome t
You can use the Content-Length header to tell the server how long the
string is.
--
http://mail.python.org/mailman/listinfo/python-list
ahh..that does make sense. But maybe getsize() should have a way of
inferring what file is specified. I might actually submit a request..
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>, flamesrock
wrote:
> os.path.getsize(infile) <= infile.tell()
>
> Because that returns the error:
> # File "/usr/lib/python2.3/posixpath.py", line 142, in getsize
> #return os.stat(filename).st_size
> #TypeError: coercing to Unicode: need string or buffer, file found
>
Thanks!
I don't know why, but the most innefficient and unmaintanable means of
doing something usually pops into my head before anything else. I
solved this by going
elif len(header) < 8:
break
--
http://mail.python.org/mailman/listinfo/python-list
In article <[EMAIL PROTECTED]>,
"flamesrock" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> So if I understand correctly, there are NO eof characters in any binary
> file. If so, is there an easier way to check for the end of the file
> than:
>
> os.path.getsize(infile) <= infile.tell()
How you detect E
81 matches
Mail list logo