problem using pickle

Nicky Mac nmcelwaine at gmail.com
Sat Mar 12 10:45:34 EST 2016


Dear Python team,
I have studied the excellent documentation, and attempted to make use of
pickle thus:

filename = 'my_saved_adventure'
import  pickle
class object:
    def __init__(self,i,.........t) :
        self.id       = i
         .....

class world:
    def __init__(self):
        self.object

class object:
    def __init__(self,i,

.....then   Object instances of object are created ........

        myworld = world;
        myworld.Object = Object
        fileobj = open(filename,'wb')
        pickle.dump(myworld,fileobj); fileobj.close()
        result = "saved your game to " + filename

        fileobj = open(filename,'rb')
        myworld = pickle.load(fileobj); fileobj.close()
        Object = myworld.Object
        result = "restored your game from " + filename


The proecedures execute without error
but a file of only 21b is created containing " €c__main__world q .
altho there are several k of object instance data.

-- 
Nick "Mac" McElwaine



More information about the Python-list mailing list