I have a python script that import a module that read a file and extract some information from it. This is like this:
import my_module
information = my_module.get_file_info(file_name)
print information.info1()
The module do:
class get_file_info():
def __init__(self, file_name):
self.file_name = file_name
def file_lines(self):
file_to_get_info = open(self.file_name, 'r')
lines = file_to_get_info.readlines()
file_to_get_info.close()
return lines
def info1(self):
info1 = do_something(self.file_lines())
return info1
The variable 'file_name' is a text file and this is NOT edited by script. When I edit the text file, my class don't see the changes in first time I run the script (like the txt file is not edited), only the second time. What's wrong?
Additional information: I call the main python script from a batch file in windows and I thought it was problem with the pyc files, so I use the "-B" parameter:
python -B main_script.py
I deleted all pyc files and my main python script also import the sys module and has a "sys.dont_write_bytecode = True", but the problem still happens.