I'm building a function that needs to operate over several files, in the following way:
def myfuntion(filenames):
n = len(filenames)
if n > 0:
data = fits.open(filenames)
for i in range(1,n):
final = *DO SOMETHING FOR EACH FILE*
return final
The idea is to call the function using several files:
mean_myfuntion(['file1.fits', 'file2.fits', 'file3.fits'])
However the problem is that I'm receiving the following error:
OSError: File-like object does not have a 'write' method, required for mode 'ostream'.
And I'm not sure what's going on. I'm suspecting that I'm missing something when calling the filenames (data = fits.open(filenames)), If you folks have any advise, it will be more than welcome.
Thanks!