lmac wrote:
> Hi there,
> i want to use an long int from an list which i got from my function 
> find_lineno().
> But i got this error and i don't understand why i can not use this long 
> as an argument.

You have the arguments to file.seek() reversed.

> Where do i find a good documentation on errors so that i complete 
> understand what
> the heck is going on.

>From http://docs.python.org/lib/bltin-file-objects.html
seek(   offset[, whence])
    Set the file's current position, like stdio's fseek(). The whence argument 
is optional and defaults to 0 (absolute file positioning); other values are 1 
(seek relative to the current position) and 2 (seek relative to the file's 
end). 

Kent

> Many thanks.
> 
> ERROR:
> ---------------------------------------------------
> Traceback (most recent call last):
>   File "./extrmails.py", line 42, in ?
>     inputfile.seek(0,li)
> IOError: [Errno 22] Invalid argument
> ---------------------------------------------------
> 
> 
> CODE-START:
> -----------------------------------------------------------------------------
> 
> inputfile=open("mails","rt")
> 
> # --------------------------------------------------------------------------
> def reset_inputfile():
>         inputfile.seek(0,0)
> 
> # --------------------------------------------------------------------------
> def find_lineno(string):
>         f = -1
>         a = "start"
>         found_lines = []
>         reset_inputfile()
> 
>         while len(a) != 0:
>                 a = inputfile.readline()
>                 f = a.find(string)
>                 if f != -1:
>                         found_lines.append(inputfile.tell())
> 
>         return found_lines
> 
> # --------------------------------------------------------------------------
> 
> from_lineno=find_lineno("From:")
> subj_lineno=find_lineno("Subject:")
> 
> print len(subj_lineno)
> print len(from_lineno)
> 
> reset_inputfile()
> 
> for li in subj_lineno:       
>     inputfile.seek(0,li)    <------ ??????? 
>     .......
>     ......
> --------------------------------------------------------------------------
> CODE-END
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to