Nubie question: how to not pass "self" in call to seek() function ?

Barak, Ron Ron.Barak at
Thu Jan 8 15:11:20 CET 2009


I am getting the error TypeError: seek() takes exactly 2 arguments (3 given), namely:

$ ./
Traceback (most recent call last):
  File "./", line 47, in <module>
  File "./", line 20, in last_line_loc_and_contents, 2) # grab the last character
TypeError: seek() takes exactly 2 arguments (3 given)

When I run the below code.

I understand that the extra argument is the "self", but I don't know how to change my class to make the seek(-1,2) work.

Could you help ?


$ cat
#!/usr/bin/env python

import gzip
import sys

from Debug import _line as line

class LogStream():

    def __init__(self, filename):
        self.filename = filename
        self.input_file = self.open_file(filename)
        self.index_increment = 10
        self.last_line_offset = -1

    def last_line_loc_and_contents(self, estimated_line_size=1024):

        assert estimated_line_size > 0
        file_size = len(, 2) # grab the last character

        if == '\n': # a "proper" text file
            file_size -= 1

    def open_file(self, in_file):
        The gzip module checks if the input file is a gzipped file, only at the read stage.
        This is why the f.readline() is needed.
            f = gzip.GzipFile(in_file, "r")
        except IOError:
            f = open(in_file, "r")

if __name__ == "__main__":
    filename = "../save_state/hp/save_state-ssp8400-0709R00004_081126-121659/var/log\\sac.log.4.gz"
    log_stream = LogStream(filename)
    log_stream.limit_ = 1000
    log_stream.index_increment = 12

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list