Python question
I've a little problem with my first python script... I've two files, one which has two functions and another one which I use for testing them. Here are the frunction:
Code:
def loaddb(file): Code:
from fileio import * Code:
Traceback (most recent call last): Thanks very much |
I believe you have to import pickle in your fileio.py file.
|
It doesn't work also... :(
|
I maybe wrong but have you defined a pickle file somewhere eg
pickle_file = open(filename, "rb") and in your first function the next line would be :- info = Pickle.load(pickle_file) BTW cPickle is quicker than pickle and works just as well. Here is an example from a program I wrote :- def writedict(self, dictent): #write dictionary to file pickle_file = open(dictfile, "wb") cPickle.dump(dictent, pickle_file) pickle_file.close() |
Quote:
PS I fixed my problem |
I used self as the function was part of a class.
How did you solve the problem ? |
All times are GMT -5. The time now is 05:27 PM. |