Trying to pass a file object to
x = open('example.txt', 'rb')
y = list(x)
y = ['aaaaa']
[<open file 'example.txt', mode 'rb' at 0x7fa03ced1300>]
Iterating through a file object iterates through the lines in the file.
for line in f: # do something with the line
The argument to
list constructor is an iterable. The argument will be iterated and the list will be created from iterated items.
list('abc') # result: ['a', 'b', 'c']
list(f) creates a list of lines read from the file.
To actually create a list containing one file object do this:
list_of_files = [f]