everyone, I have problems with reading the file, the result of the function returns the old data (possibly cached). For example, the argument which parsed differs from the real. How to disable any cache in python and always get valid result? Here is my code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
file_name = 'file.conf'
if os.path.exists(file_name) :
with open(file_name, 'r') as f :
b = bool(f.read().split()[2])
if b == True:
print('Result is true!' )
elif b == False :
print('Result is false!')
else :
print('Parse error!')
else :
with open(file_name, 'w') as f:
f.write('display_message_startup = False')
Python 3.5.2, Ubuntu 16.04.3 x86_64