Python 2.5 does not have the with
code block support.
Do this instead:
myfile = open(file, "r")
try:
data = myfile.read()
p = re.compile(exp)
matches = p.findall(data)
for match in matches:
print " ".join("{0:02x}".format(ord(c)) for c in match)
finally:
myfile.close()
note: you should not use file
as the name of your file, it is an internal Python name, and it shadows the built in.