1

I use with statement in python script:

ReadFile = open(file, "r")
                with ReadFile as f:  
                    for line in f:
                        print line

I use python 2.5, but this script could be used in older python versions. And in those versions there is error:

with ReadFile as f:
            ^
SyntaxError: invalid syntax

could someone advise me some alternatives for with statement in python for versions earlier that 2.5?

khris
  • 4,501
  • 18
  • 60
  • 93

0 Answers0