(original) (raw)

Hello list.
 
I'm trying to get the following code to work:
 
def getlog(activity,type,endtype):
    log = open("Multivert\_Log.txt","r")
    for line in log.readlines():
        ac = re.compile(activity)
        fac = re.findall(ac, line)
        if fac:
            print line
            break
        else:
            print "Uh-oh."
    log.close()
    logagain = open("Multivert\_Log.txt","r")
    ty = re.compile(type)
    fty = re.findall(ty,line)
    for line in logagain.readlines():
        if not fty:
            fty = re.findall(ty,line)
        elif fty:
            print line
            break
    logagain.close()
    ex = re.compile("\\d")
    fex = re.findall(ex,line)
    logain = open("Multivert\_Log.txt","r")
    for line in logain.readlines():
        if not fex:
            fex = re.findall(ex,line)
        elif fex:
            print line
            break
If, for example, \[readlines():\] returns:
 
"CALCULATION
 
 
 
 
 
EXPONENTS
 
 
 
1 \*\* 1 = 1
",
the code poduces:
 
"CALCULATION
 
 
 
"
 
Any suggestions as to how to go about this, as well as to why the program behaves this way, are welcome.
 
Thanks in advance,
Orri
 
Email: dragonfirebane@aol.com
AIM: singingxduck
Programming Python for the fun of it.