[Tutor] Re: problems with re module

Lee Harr missive at hotmail.com
Sat Nov 15 19:40:41 EST 2003


>the output is:
>
><row>type of col is: <type 'str'>       Col is: Race
>

You are using CurrentLine in two different places, and
in two different ways.  Here at the beginning, it is
a string...


CurrentLine = ""
for line in f:
        if line.isspace() or line == '':
                pass
        elif line[0] == '+':
                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
                        if CurrentLine:
                                writeln('<row>')
                                #process the line here:
                                CurrentLine = 
string.split(CurrentLine,'|')[1:-1]


and now here, you change it in to a list.

Try changing the name of one of these, or rethinking your algorithm.

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail




More information about the Tutor mailing list