Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #104757

problem using pickle

From Nicky Mac <nmcelwaine@gmail.com>
Newsgroups comp.lang.python
Subject problem using pickle
Date 2016-03-12 15:45 +0000
Message-ID <mailman.62.1457870512.12893.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

problem using pickle Nicky Mac <nmcelwaine@gmail.com> - 2016-03-12 15:45 +0000

csiph-web