Re: [Tutor] Pickling files in Python

2011-11-19 Thread Walter Prins
Hi Joe, On 19 November 2011 13:28, Joe Batt wrote: > I am new to programming and on a very steep curve. I am using Python 3 to > learn and I am having trouble understanding exactly what pickling is. > I have written a program that asks for a URL and then writes the source > code from the URL to

[Tutor] Pickling files in Python

2011-11-19 Thread Joe Batt
Hi all I am new to programming and on a very steep curve. I am using Python 3 to learn and I am having trouble understanding exactly what pickling is. I have written a program that asks for a URL and then writes the source code from the URL to a file, then pickles the file I just creat

[Tutor] Pickling Class Instances

2011-10-31 Thread Rinu Boney
I have a class 'book' and function for input and display of the class members then there are 2 functions for pickling and unpickling class instances from and to a file. after unpickling , then displaying it shows only the last class instance stored in the file! what can be the possible problems? __

[Tutor] pickling codecs

2010-09-08 Thread Dinesh B Vadhia
I use codecs to retain consistent unicode/utf-8 encoding and decoding for reading/writing to files. Should the codecs be applied when using the pickle/unpickle function? For example, the standard syntax is: # pickle object f = open(object, 'wb') pickle.dump(object, f, 2) # unpickle object f

Re: [Tutor] pickling/shelve classes

2010-06-18 Thread Payal
On Thu, Jun 17, 2010 at 11:11:11AM +0200, Eike Welk wrote: > I think it is a bug in IPython: I can do this in regular Python, but in > IPython I get the same error that you get: > Thanks a lot. It works in normal python. Thanks again. With warm regards, -Payal --

Re: [Tutor] pickling/shelve classes

2010-06-17 Thread Eike Welk
On Thursday June 17 2010 11:11:11 Eike Welk wrote: > You should file a bug report in their bug tracker: > http://github.com/ipython/ipython/issues I believe tthis is the bug: http://github.com/ipython/ipython/issues/#issue/29 It seems that objects defined on IPython's top-level can't be pickled.

Re: [Tutor] pickling/shelve classes

2010-06-17 Thread Eike Welk
Hello Payal! On Thursday June 17 2010 04:48:19 Payal wrote: > Hi all, > Can someone please help in this below? > > class F(object) : >...: def __init__(self, amt) : self.amt = amt >...: def dis(self) : print 'Amount : ', self.amt >...: def add(self, na) : >...:

[Tutor] pickling/shelve classes

2010-06-16 Thread Payal
Hi all, Can someone please help in this below? class F(object) : ...: def __init__(self, amt) : self.amt = amt ...: def dis(self) : print 'Amount : ', self.amt ...: def add(self, na) : ...: self.amt += na ...: F.dis(self) pickle.dumps(F) gives PicklingEr

Re: [Tutor] pickling, writing, reading individual lists from a file

2008-11-03 Thread Dinesh B Vadhia
Just one change - pickler.load() doesn't take an argument - otherwise works perfectly! Thank-you. ... 6. Make multiple calls to dump() and load() using an explicit pickler, pickling directly to the file (not tested): import cPickle as pickle filename = 'lists.txt' fw = open(filename, 'wb')

Re: [Tutor] pickling, writing, reading individual lists from a file

2008-11-03 Thread Lie Ryan
On Mon, 03 Nov 2008 06:42:28 -0500, Kent Johnson wrote: > On Mon, Nov 3, 2008 at 6:15 AM, Lie Ryan <[EMAIL PROTECTED]> wrote: >> On Sun, 02 Nov 2008 23:20:47 -0800, Dinesh B Vadhia wrote: >> >>> I want to pickle a bunch of lists and write each list separately to a >>> fileand then read them back.

Re: [Tutor] pickling, writing, reading individual lists from a file

2008-11-03 Thread Kent Johnson
On Mon, Nov 3, 2008 at 6:15 AM, Lie Ryan <[EMAIL PROTECTED]> wrote: > On Sun, 02 Nov 2008 23:20:47 -0800, Dinesh B Vadhia wrote: > >> I want to pickle a bunch of lists and write each list separately to a >> fileand then read them back. > To solve your problem, you have several alternative possibil

Re: [Tutor] pickling, writing, reading individual lists from a file

2008-11-03 Thread Lie Ryan
On Sun, 02 Nov 2008 23:20:47 -0800, Dinesh B Vadhia wrote: > I want to pickle a bunch of lists and write each list separately to a > fileand then read them back. Here is my code with the EOF error: > > filename = 'lists.txt' > fw = open(filename, 'w') > for l in m: > n = pickle.dumps(l,

[Tutor] pickling, writing, reading individual lists from a file

2008-11-02 Thread Dinesh B Vadhia
I want to pickle a bunch of lists and write each list separately to a fileand then read them back. Here is my code with the EOF error: import cPickle as pickle m = [[1, 2, 3, 4], [5, 6, 7, 8, 9, 10], [11, 12, 13, 14]] filename = 'lists.txt' fw = open(filename, 'w') for l in m: n = pick

Re: [Tutor] pickling and unpickling custom classes

2008-10-28 Thread Kent Johnson
On Mon, Oct 27, 2008 at 11:40 PM, Lex Flagel <[EMAIL PROTECTED]> wrote: > I'm using a simple class called Hash, which I picked up from the following > site: > http://mail.python.org/pipermail/python-list/2007-August/453716.html > > I like using this Hash object for its convenience, but it won't >

[Tutor] pickling and unpickling custom classes

2008-10-28 Thread Lex Flagel
I'm using a simple class called Hash, which I picked up from the following site: http://mail.python.org/pipermail/python-list/2007-August/453716.html I like using this Hash object for its convenience, but it won't unpickle. Is there fix to the code example below (either the pickler or the Hash ob

Re: [Tutor] Pickling in plain English

2005-05-24 Thread Tom Tucker
John, Thanks that did help. Like usual, I was making it harder than necessary. Tom, I concur! Well put! On 5/24/05, Tom Cloyd <[EMAIL PROTECTED]> wrote: > I just want to take a moment to express my deep appreciation for this > List. As one who is learning Python as amateur, in my spare moments

Re: [Tutor] Pickling in plain English

2005-05-24 Thread Tom Cloyd
I just want to take a moment to express my deep appreciation for this List. As one who is learning Python as amateur, in my spare moments, and already getting it to do good work for me, these clear, beautifully worked descriptions of basic aspects of Python are simply an ongoing delight for

Re: [Tutor] Pickling in plain English

2005-05-24 Thread jfouhy
Quoting Tom Tucker <[EMAIL PROTECTED]>: > I am having trouble understanding the c|Pickle modules. What does > serializing and de-serializing objects mean? I have read the below > urls and I "think" I understand the process, but I can't visualize the > beneifts. Can someone kindly explain pickling

[Tutor] Pickling in plain English

2005-05-24 Thread Tom Tucker
I am having trouble understanding the c|Pickle modules. What does serializing and de-serializing objects mean? I have read the below urls and I "think" I understand the process, but I can't visualize the beneifts. Can someone kindly explain pickling in lamens terms? Thanks, Tom http://effbot

Re: [Tutor] Pickling

2005-02-13 Thread Kent Johnson
Johan, The problem is in your class V. You have class V: a=[] def add(self, s): self.a.append(s) The problem is that 'a' is a *class* variable, not an instance variable. The correct way to define V is like this: class V: def __init__(self): self.a=[] # Now 'a