It should now work with python2 and python3.
def repl(match, self=self):
"return the eval of a found expression, for replacement"
# uncomment for debug:
def repl(match, self=self):
"return the eval of a found expression, for replacement"
# uncomment for debug:
- # print '!!! replacing',match.group(1)
+ # print '!!! replacing',match.group(1)
expr = self.preproc(match.group(1), 'eval')
try: return str(eval(expr, self.globals, self.locals))
except: return str(self.handle(expr))
expr = self.preproc(match.group(1), 'eval')
try: return str(eval(expr, self.globals, self.locals))
except: return str(self.handle(expr))
stat = self.preproc(stat, 'exec')
stat = '%s _cb(%s,%s)' % (stat,i+1,j)
# for debugging, uncomment...:
stat = self.preproc(stat, 'exec')
stat = '%s _cb(%s,%s)' % (stat,i+1,j)
# for debugging, uncomment...:
- # print "-> Executing: {"+stat+"}"
- exec stat in self.globals,self.locals
+ # print "-> Executing: {"+stat+"}"
+ exec(stat, self.globals, self.locals)
i=j+1
else: # normal line, just copy with substitution
self.ouf.write(self.regex.sub(repl,line))
i=j+1
else: # normal line, just copy with substitution
self.ouf.write(self.regex.sub(repl,line))