I can't load multiple times a file with inside of it an empty list
<p>I need to load more than one time a file with inside of it and empty list.
At first I tried:</p>

<pre><code>import pickle
file_example = open("file.cpk","wb")
empty_list = []
pickle.dump(empty_list,file_example)
file_example.close()

def file_open():
    file_open.file = open("file.pck","rb")
    file_open.empty_list = pickle.load(file_open.file)
    file_open.empty_list = pickle.load(file_open.file)
    file_open() 
file_open()
</code></pre>

<p>but it said "Ran out of input". I found that I have to use .seek to load more than one time the same file, so I did this:</p>

<pre><code>import pickle
file_example = open("file.cpk","wb")
empty_list = []
pickle.dump(empty_list,file_example)
file_example.close()

def file_open():
    file_open.file = open("file.pck","rb")
    file_open.empty_list = pickle.load(file_open.file)
    file_open.empty_list.seek(0)
    file_open.empty_list = pickle.load(file_open.file)
file_open()
</code></pre>

<p>And now says "'list' object has no attribute 'seek'". How can I load more than one time that file?</p>

<p>You need to call seek on the file object:</p>

<pre><code>import pickle
file_example = open("file.pck","wb")
empty_list = []
pickle.dump(empty_list,file_example)
file_example.close()

def file_open():
    file_open.file = open("file.pck","rb")
    file_open.empty_list = pickle.load(file_open.file)
    file_open.file.seek(0)
    file_open.empty_list = pickle.load(file_open.file)
file_open()
</code></pre>

python