I've read a lot of similar questions, but the majority of them were solved by fixing the indentation so either i'm clueless or there's some easy way of fixing my problem but i dont think it is about identation.
So i have this function that basically performs a couple of operations using two *.txt files and returns a generator object of namedtuples with some info i need to look up later.
def master_reader(file1, file2):
with open(file1, "r", encoding="utf-8") as genomas:
with open(file2, "r", encoding="utf-8") as listas:
l = parser_listas(listas)
f = parser_genomas(genomas)
f = map(intifier, f)
f = (people_maker(linea, l) for linea in f)
f = map(genotipo_getter, f)
f = map(fen_getter, f)
return f
The thing is everything works fine when i call it and assign it to a variable.But i need to use it as a parameter so i can call it everytime i need it for some queries i need to perform over it:
print(valor_caracteristica("TCT", "Luna Lovegood", master_reader("genomas.txt", "listas.txt")))
But i am getting this exception:
Original exception was:
Traceback (most recent call last):
File "lib.py", line 204, in <module>
print(valor_caracteristica("TCT", "Luna Lovegood", master_reader("genomas.txt", "listas.txt")))
File "lib.py", line 194, in valor_caracteristica
a = next(filter(lambda x: x.nombre == nombre, file))
File "lib.py", line 185, in <genexpr>
f = (people_maker(linea, l) for linea in f)
ValueError: I/O operation on closed file.