don't understand error message

Steve Holden sholden at
Tue Sep 17 12:33:25 EDT 2002

"Manuel Hendel" <manuel at> wrote in message
news:mailman.1032255920.1725.python-list at
> On Tue, Sep 17, 2002 at 09:12:06AM +0000, Duncan Booth wrote:
> > It simply means that at least one line of your file doesn't have 4
> > after you have finished your processing. If the line only has two "|"
> > characters in it, then you will only get three fields which you can
> > with indices 0 to 2. Trying to use an index out of range for a list will
> > produce this error.
> >
> > Try sticking a "print fields" line just before the if statement, the
> > line printed will show you which line didn't match.
> My script already changed a little bit, I tried to fix it by my self,
> but it seams, that I just moved the error. How would you check the
> lines for the number of fields?
> Actually, I think I found that problem. I forgot some "---|--|--" at
> the end.
> But I already got a new one.
> [....]
> if domainfield in domain:
>     domainlines.append(line)
> [....]
> This should work if the domainfield and domain got the following
> values, shouldn't it?
> domainfield =
> damain =
> But I get this error message:
> TypeError: 'in <string>' requires character as left operand

You're just a little bit ahead of reality (have you been using Guido's time
machine without permission?). This should woirk in 2.3, but for now you'll
have to use the .index() or .find() methods of the string objects.

Steve Holden                        
Python Web Programming       
Previous .sig file retired to          

More information about the Python-list mailing list