Problem using lseek

michael benjamin mayhew mayhew.24 at osu.edu
Wed Feb 5 19:22:38 CET 2003


Padraig,

    Thanks. I realized immediately after I had posted the message that I was
trying to manipulate
a file object without passing the descriptor (an integer), hence the
TypeError. Don't I feel stupid.
Thanks again.

Michael

Padraig at Linux.ie wrote:

> Michael Mayhew wrote:
> > Greetings,
> >
> >     I have been using Python faithfully for the past five months and am
> > quite happy having learned it. That being said, I am currently having a
> > real honey of a problem. I am trying to use the os module's lseek
> > function to set a file descriptor to a new offset position in a file.
> > However, when running the code through the interpreter, I continue
> > receiving a TypeError message:
> >
> > Traceback (most recent call last):
> >   File "testseq.py", line 18, in ?
> >     os.lseek(somefile, someoffset, 1)
> > TypeError: an integer is required
>
> Is this what you want?
> os.lseek(somefile.fileno(), someoffset, 1)
>
> note also:
> somefile.seek()
>
> Pádraig.





More information about the Python-list mailing list