don't understand error message

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


"Manuel Hendel" <manuel at hendel.net> wrote in message
news:mailman.1032255920.1725.python-list at python.org...
> 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
fields
> > 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
access
> > 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
last
> > 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 = 1234.ab.cdef.de
> damain = 1234.ab.cdef.de
>
> 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.

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com
-----------------------------------------------------------------------






More information about the Python-list mailing list