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


Groups > comp.lang.python > #104757

problem using pickle

Path csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Nicky Mac <nmcelwaine@gmail.com>
Newsgroups comp.lang.python
Subject problem using pickle
Date Sat, 12 Mar 2016 15:45:34 +0000
Lines 39
Message-ID <mailman.62.1457870512.12893.python-list@python.org> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de 2dXcrtDbF7+RKhA13ZDFoQ2uS42P/YGH796FdYUASNVQ==
Return-Path <nmcelwaine@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.073
X-Spam-Evidence '*H*': 0.86; '*S*': 0.00; 'filename': 0.07; 'attempted': 0.09; 'subject:using': 0.09; 'python': 0.10; 'def': 0.13; '........': 0.16; 'nick': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'world;': 0.16; 'team,': 0.18; 'subject:problem': 0.22; 'import': 0.24; 'skip:_ 20': 0.26; 'error': 0.27; 'message-id:@mail.gmail.com': 0.27; '&quot;': 0.29; 'pickle': 0.29; 'skip:_ 10': 0.32; 'skip:. 10': 0.32; 'class': 0.33; 'instances': 0.33; "skip:' 20": 0.34; 'file': 0.34; 'received:google.com': 0.35; 'instance': 0.35; 'but': 0.36; 'there': 0.36; 'created': 0.36; 'received:209.85': 0.36; 'data.': 0.36; 'to:addr:python-list': 0.36; 'skip:& 10': 0.37; 'received:209': 0.38; 'several': 0.38; 'skip:p 20': 0.38; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; '8bit%:31': 0.66; '\xc2\xa0\xc2\xa0': 0.66; 'skip:\xc2 10': 0.67; 'dear': 0.67; '8bit%:100': 0.70; 'skip:\xe2 10': 0.70; '.....': 0.76; 'object:': 0.84; 'url:self': 0.84; 'world:': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=DUX89xyRBRoIg6U062EJBDK8aT61fEgPyEm0oWIRVfY=; b=0rCj5ViCOOtzCI525s0Y4I41PGXAYYczccgD1t+LtnIHCOTNqeQ9bDYM+rF0AKJPIH cSqu1YeSre8VEcPcqe/JVg/sN2+7JKd2CdElq1ogZXdvjmbSGh7AyhbEqi/Pon3OzGgp z8G8Pq6E9YBaXJZnT2HdKS5KjbdI5c9zucd7I9tWQAaC2XRA0jKTPHWIfLG3IpDO/mM7 zZe7CqiSTiJCuSIe1dR8/GtHcZbqhrUpP9jw/2WqryvOugOLBBR+NqegaH53FsS57LHC BkC5Uu5YeB9ZHcH4hEntZ0FbRTPPVpFup6ulRuExf35ryrf9PXV3Xndo80V8e+wiv7DY jmzQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=DUX89xyRBRoIg6U062EJBDK8aT61fEgPyEm0oWIRVfY=; b=ieLutfOKUm+KKt1LxBa4yuDqUD3SkmcSFzZhtNqgdC26Fa9GcoVRAf8Ej+lhaZgIDz qcK9JmVFiROA91uf5zOmlgf685vKk4LPARUHNLZJlPD9YQQ8sq7W6fWDGVeysJQ0XY7e nb9IlQ7WELNDHXq5nCT+2yK5LNDusGlR24Rm4yBaeFICZUaKMcYq77msMUIO6NzjIgVC fcLSwxOxQdxXuCyzljWix7UAXih3jfltl1XCh0ZwPbh413gmFdoG67KJxcjGtoNVwF7c GyOljB+DIBaoqnKesnCQGe+G5aveLc9TYXKKhMNBUbW0xD5fX7UI6aAU2DPjEO0MBhGW rNBw==
X-Gm-Message-State AD7BkJLhR+1/kNueXTIbX8kWLFTll7C20VlnOe6DbU8lAlmW0LeZoibqlCrldUftlXL025H0jvGWuHyFw403FA==
X-Received by 10.182.65.138 with SMTP id x10mr8906003obs.39.1457797534489; Sat, 12 Mar 2016 07:45:34 -0800 (PST)
X-Mailman-Approved-At Sun, 13 Mar 2016 08:01:50 -0400
X-Content-Filtered-By Mailman/MimeDel 2.1.21
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:104757

Show key headers only | 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