file's tell() method appears crazily broken (2.0)
sholden at holdenweb.com
Sun Jan 27 18:41:18 CET 2002
"Bengt Richter" <bokr at oz.net> wrote in message
news:a31cuk$san$0 at 18.104.22.168...
> On Sun, 27 Jan 2002 15:02:00 GMT, "Steve Holden" <sholden at holdenweb.com>
> >Sorry if this is an old error, I couldn't find anything on SourceForge.
> >really like to know if it's repeatable in other environments.
> >I cam across this when the rfc822 library failed reading a file
> >newsgroup post. Some debugging led me to a really simple program which
> >exhibits the same error:
> >import sys
> >fp = open(sys.argv, "r")
> >print "File open at", fp.tell()
> I'd guess you need "rb" for tell to work properly on non-unix platforms.
Well, duh. The need to open files in binary to use tell() has bitten me in
the ass before, I guess it's true, you can't teach an old dog new tricks.
> Still, an informative error message from tell might be nice if it knows
> what's happening.
I agree, though I'm not sure whether tell() can sensibly work this out. The
message could be something like "Programmer finger trouble: tell() should be
used only in binary mode".
Thanks for pointing out the error of my ways.
Consulting, training, speaking: http://www.holdenweb.com/
Python Web Programming: http://pydish.holdenweb.com/pwp/
More information about the Python-list