[Tutor] Re: problems with re module

Lee Harr missive at hotmail.com
Sun Nov 16 08:17:23 EST 2003


CurrentLine = ""
for line in f:
    if line.isspace() or line == '':
        pass

    elif line[0] == '+':  # I think maybe you want != here

        if initial:
            writeln("<tgroup cols='%d'>\n<tbody>\n" % 
(len(string.split(line,'+')[1:-1]) ))
            initial=False
        else:
            #can we assume that formatting ends with a newline? probably - 
for the time being.

            if CurrentLine: # so the first time through, do nothing.
                            # second time, CurrentLine will actually be the
                            # previous line. This is very confusing.

                writeln('<row>')
                #process the line here:
                Line = string.split(CurrentLine,'|')[1:-1]
                for col in Line:

                    # instead of just checking col, try looking at
                    # line, Line, and CurrentLine here.

                    print "type of col is: %s \tCol is: %s" % 
(type(col),string.strip(col))
                    writeln('<entry>%s</entry>' % procol(string.strip(col)) 
)
                writeln('</row>\n')

            CurrentLine = ""

    else:
        CurrentLine = CurrentLine + line

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail




More information about the Tutor mailing list