Hello everybody! Me again with an other question :)
I have a file with a list and 3 functions in it; view, sort, append.
I used pickle to save data changes in to an other file (films.db).
Imagine you want to use this programe for the first time on your system so there is no db file correct?
You should type python favemoviese.py view or favemovies.py append.... At this time the script must creat the db file immidiately beacuse there was no primary db file, right?
And then you should be able to append your word to the list because the db file has been created jaut a few seconds ago.
But when i do type python favemovies.py append or view, an error appears that say there is no db file to load data from, and after that an empty db file will be created immidiately.
Why? How can i create the db file first.
Really orry for long discribtion!! I just didnt know how to explaine the problem, just wanted to make it clear.
I've type this above all functions:
#!/usr/bin/env python3
# -*-coding: utf8-*-
filename = 'films.db'
target = open (filename, 'a')
import pickle
favorite_movies=[]
favorite_movies = pickle.load( open("films.db", "rb"))
def append():
I want filename and target work first to create the db file but the programe reads the pickle.load line first.