I have a kinda weird problem, here is my attempt at an explanation:
I'm currently making a program which opens a txt file and then reads a line for that file, using the following command linecache.getline(path,number), after the function is done I then use commmand linecache.clearcache.
If I then change something in the text file it keeps returning the pre-changed line.
Following is the code I'm using (I know it aint really pretty)
def SR(Path,LineNumber):
returns = lc.getline(Path,LineNumber)
x = np.array([])
y = np.array([])
words = returns.split()
for word in words:
x = np.append([x],[word])
for i in range(len(x)):
t = float(x[i])
y = np.append([y],[t])
return y
del x
del y
del t
del words
lc.clearcache()
Nothing after the return
statement will ever be executed. If you want to call clearcache
, you need to call it before the return
statement.
Also, as a side note, your del
statements aren't really going to do anything either, even if they were placed before the return
. del
effectively just decrements the reference counter in the gc, which will happen when the interpreter exits the function scope anyway.