Re: Pickle problem while loading a class instance.

2010-04-09 Thread Peter Otten
gerardob wrote: > > I tried both things: > > 1- moved all the code to C:/Python26/lib/site-packages > 2- Modified the PYTHONPATH in the windows registry. > > However, i stil have exactly the same error on the screen. > > Any other suggestions? Did you heed my advice and make sure that your sc

Re: Pickle problem while loading a class instance.

2010-04-09 Thread Gabriel Genellina
En Fri, 09 Apr 2010 18:42:23 -0300, gerardob escribió: I tried both things: 1- moved all the code to C:/Python26/lib/site-packages 2- Modified the PYTHONPATH in the windows registry. However, i stil have exactly the same error on the screen. Any other suggestions? Did you follow the advi

Re: Pickle problem while loading a class instance.

2010-04-09 Thread gerardob
I tried both things: 1- moved all the code to C:/Python26/lib/site-packages 2- Modified the PYTHONPATH in the windows registry. However, i stil have exactly the same error on the screen. Any other suggestions? Thanks. Peter Otten wrote: > > gerardob wrote: > >> Hello, I am new to python a

Re: Pickle problem while loading a class instance.

2010-04-06 Thread Lie Ryan
On 04/07/10 03:23, gerardob wrote: > The error below appears. In the case i remove the comment to initialize m2, > the same thing happens. Any ideas on how to fix this? > When unpickling a user-defined class, you unpickling module must have access to the original class definition. This means if

Re: Pickle problem while loading a class instance.

2010-04-06 Thread Peter Otten
gerardob wrote: > Hello, I am new to python and i have a problem using the pickle load > function. > I have an object m of the class MarkovModel and i want to copy it to a > file and load it onto another class: > > l=[1,2,3] > m = markov_model.MarkovModel() > m.load_observations(l) > file = open(

Re: Pickle Problem

2009-03-05 Thread MRAB
Fab86 wrote: On Mar 4, 2:49 pm, MRAB wrote: Fab86 wrote: On Mar 4, 1:40 am, "Gabriel Genellina" wrote: En Tue, 03 Mar 2009 23:11:30 -0200, Fab86 escribió: On Mar 4, 12:00 am, MRAB wrote: Fab86 wrote: On Mar 3, 8:59 pm, "Gabriel Genellina" wrote: How to "spell" exactly the exception nam

Re: Pickle Problem

2009-03-05 Thread Fab86
On Mar 4, 2:49 pm, MRAB wrote: > Fab86 wrote: > > On Mar 4, 1:40 am, "Gabriel Genellina" wrote: > >> En Tue, 03 Mar 2009 23:11:30 -0200, Fab86 escribió: > > >>> On Mar 4, 12:00 am, MRAB wrote: > Fab86 wrote: > > On Mar 3, 8:59 pm, "Gabriel Genellina" wrote: > >> How to "spell" exa

Re: Pickle Problem

2009-03-04 Thread Lie Ryan
Fab86 wrote: Is there another way rather than closing the file? Is it possible to delete all within the file? Thanks Delete the old file then opening (and creating) it again is the easiest way? If you need the data from the old file, you can rename the old file and reopen (and create) a new

Re: Pickle Problem

2009-03-04 Thread MRAB
Fab86 wrote: On Mar 4, 1:40 am, "Gabriel Genellina" wrote: En Tue, 03 Mar 2009 23:11:30 -0200, Fab86 escribió: On Mar 4, 12:00 am, MRAB wrote: Fab86 wrote: On Mar 3, 8:59 pm, "Gabriel Genellina" wrote: How to "spell" exactly the exception name should appear in the documentation; migh

Re: Pickle Problem

2009-03-04 Thread Fab86
On Mar 4, 1:40 am, "Gabriel Genellina" wrote: > En Tue, 03 Mar 2009 23:11:30 -0200, Fab86 escribió: > > > > > On Mar 4, 12:00 am, MRAB wrote: > >> Fab86 wrote: > >> > On Mar 3, 8:59 pm, "Gabriel Genellina" wrote: > >> >> How to "spell" exactly the exception name should appear in the   > >> >> d

Re: Pickle Problem

2009-03-03 Thread Gabriel Genellina
En Tue, 03 Mar 2009 23:11:30 -0200, Fab86 escribió: On Mar 4, 12:00 am, MRAB wrote: Fab86 wrote: > On Mar 3, 8:59 pm, "Gabriel Genellina" wrote: >> How to "spell" exactly the exception name should appear in the   >> documentation; might be yahoo.SearchError, or yahoo.search.SearchError,

Re: Pickle Problem

2009-03-03 Thread Fab86
On Mar 4, 12:00 am, MRAB wrote: > Fab86 wrote: > > On Mar 3, 8:59 pm, "Gabriel Genellina" wrote: > >> En Tue, 03 Mar 2009 16:50:25 -0200, Fab86 escribió: > > >>> On Mar 3, 6:48 pm, "Gabriel Genellina" wrote: > En Tue, 03 Mar 2009 16:39:43 -0200, Fab86   > escribió: > > I am havin

Re: Pickle Problem

2009-03-03 Thread MRAB
Fab86 wrote: On Mar 3, 8:59 pm, "Gabriel Genellina" wrote: En Tue, 03 Mar 2009 16:50:25 -0200, Fab86 escribió: On Mar 3, 6:48 pm, "Gabriel Genellina" wrote: En Tue, 03 Mar 2009 16:39:43 -0200, Fab86 escribió: I am having a bit on an issue getting my program to work. The online databas

Re: Pickle Problem

2009-03-03 Thread Tim Wintle
On Tue, 2009-03-03 at 15:33 -0800, Fab86 wrote: > I have been trying except SearchError: however I get the error: > > Traceback (most recent call last): > File "C:\Downloads\MoS\yws-2.12\Python\pYsearch-3.1\timeDelay.py", > line 19, in > except SearchError: > NameError: name 'SearchError' i

Re: Pickle Problem

2009-03-03 Thread Fab86
On Mar 3, 8:59 pm, "Gabriel Genellina" wrote: > En Tue, 03 Mar 2009 16:50:25 -0200, Fab86 escribió: > > > > > On Mar 3, 6:48 pm, "Gabriel Genellina" wrote: > >> En Tue, 03 Mar 2009 16:39:43 -0200, Fab86   > >> escribió: > > >> > I am having a bit on an issue getting my program to work. The onli

Re: Pickle Problem

2009-03-03 Thread Gabriel Genellina
En Tue, 03 Mar 2009 16:50:25 -0200, Fab86 escribió: On Mar 3, 6:48 pm, "Gabriel Genellina" wrote: En Tue, 03 Mar 2009 16:39:43 -0200, Fab86 escribió: > I am having a bit on an issue getting my program to work. The online > database which I am trying to contact keep timing out meaning I can

Re: Pickle Problem

2009-03-03 Thread Fab86
On Mar 3, 6:48 pm, "Gabriel Genellina" wrote: > En Tue, 03 Mar 2009 16:39:43 -0200, Fab86 escribió: > > > I am having a bit on an issue getting my program to work. The online > > database which I am trying to contact keep timing out meaning I can > > not carry out my 200 searches without being in

Re: Pickle Problem

2009-03-03 Thread Gabriel Genellina
En Tue, 03 Mar 2009 16:39:43 -0200, Fab86 escribió: I am having a bit on an issue getting my program to work. The online database which I am trying to contact keep timing out meaning I can not carry out my 200 searches without being interupted. I believe that the solution would be to include a

Re: Pickle Problem

2009-03-03 Thread Fab86
On Mar 3, 1:02 pm, MRAB wrote: > Fab86 wrote: > > I am getting res1 and res2 etc from this code: > > > srch1 = WebSearch(app_id=YahooKey) > > srch1.query = "avoir site:.al" > > res1 = srch1.parse_results() > > > srch2 = WebSearch(app_id=YahooKey) > > srch2.query = "avoir site:.fr" > > res2 = srch2

Re: Pickle Problem

2009-03-03 Thread MRAB
Fab86 wrote: I am getting res1 and res2 etc from this code: srch1 = WebSearch(app_id=YahooKey) srch1.query = "avoir site:.al" res1 = srch1.parse_results() srch2 = WebSearch(app_id=YahooKey) srch2.query = "avoir site:.fr" res2 = srch2.parse_results() After identifying res1, I then use the total

Re: Pickle Problem

2009-03-03 Thread Fab86
I am getting res1 and res2 etc from this code: srch1 = WebSearch(app_id=YahooKey) srch1.query = "avoir site:.al" res1 = srch1.parse_results() srch2 = WebSearch(app_id=YahooKey) srch2.query = "avoir site:.fr" res2 = srch2.parse_results() After identifying res1, I then use the total_results_availa

Re: Pickle Problem

2009-03-03 Thread odeits
On Mar 3, 4:16 am, Fab86 wrote: > Thanks, this seems like a simpler way to do it. > > I plan on recording 200 values to this file from the outcome of 200 > Yahoo searches. Is there any type of loop I can make to do this or do > I have to have a line like "print >> f, res1.total_results_available"

Re: Pickle Problem

2009-03-03 Thread Fab86
Thanks, this seems like a simpler way to do it. I plan on recording 200 values to this file from the outcome of 200 Yahoo searches. Is there any type of loop I can make to do this or do I have to have a line like "print >> f, res1.total_results_available" 200 times? Regards, Fabien On Mar 3, 12

Re: Pickle Problem

2009-03-03 Thread Fab86
Fantastic, just what I was looking for Andrew. Many thanks, Fabien On Mar 3, 11:50 am, "andrew cooke" wrote: > Fab86 wrote: > > I am wanting to store the integers in a file so that I can then run it > > through some software without having to edit it. Will json enable me > > to do this? > > no.

Re: Pickle Problem

2009-03-03 Thread andrew cooke
maybe the following are simpler as they use print if you are using python 2.6 or python 3: >>> from __future__ import print_function >>> f = open('myfile.txt', 'w') >>> print(123, file=f) >>> print(456, file=f) >>> f.close() alternatively, in python 2.5 or 2.6: >>> f = open('myfile.txt', 'w'

Re: Pickle Problem

2009-03-03 Thread andrew cooke
Fab86 wrote: > I am wanting to store the integers in a file so that I can then run it > through some software without having to edit it. Will json enable me > to do this? no. ignore json - it is for something else entirely. all you need to do is to write the numbers out to a file: f = open('fil

Re: Pickle Problem

2009-03-03 Thread Hrvoje Niksic
Fab86 writes: > when trying to pickle them they are displayed like this: > > I14 > .I15200 > .I86000 > . > > But in console simply printing these attributes I get: > > 14 > 15200 > 86000 > > Can anyone help? Can you describe the problem in some detail? Everything seems to be working fi

Re: Pickle Problem

2009-03-03 Thread Fab86
On Mar 3, 10:34 am, Chris Rebert wrote: > On Tue, Mar 3, 2009 at 1:52 AM, Fab86 wrote: > > Hello, > > > I am new to using Python and am looking at exporting some of my code > > into a seperate document. > > > The code I am using for the pickle is: > > > file = open('testdoc.txt', 'w') > > > pickl

Re: Pickle Problem

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 1:52 AM, Fab86 wrote: > Hello, > > I am new to using Python and am looking at exporting some of my code > into a seperate document. > > The code I am using for the pickle is: > > file = open('testdoc.txt', 'w') > > pickle.dump(res1.total_results_available,file) > pickle.dump

Re: pickle problem

2008-05-11 Thread castironpi
On May 11, 6:21 pm, [EMAIL PROTECTED] wrote: > On May 8, 7:29 pm, [EMAIL PROTECTED] wrote: > > > > > > > On May 8, 4:35 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > > > > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > > > > > On Thu, 08 May 2008 08:55:35 -0700, krustymonkey wrote: > > > >

Re: pickle problem

2008-05-11 Thread krustymonkey
On May 8, 7:29 pm, [EMAIL PROTECTED] wrote: > On May 8, 4:35 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > > > > > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > > > > On Thu, 08 May 2008 08:55:35 -0700, krustymonkey wrote: > > > >> The thing is, I'm not using slots by choice. I'm using t

Re: pickle problem

2008-05-09 Thread Hrvoje Niksic
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: >> Of course, if it makes sense to pickle sockets in the application, one >> is can do so by defining __getstate__ and __setstate__: > > When does it make sense!? When recreating the object from on-disk state requires reestablishing the communi

Re: pickle problem

2008-05-08 Thread Marc 'BlackJack' Rintsch
On Thu, 08 May 2008 23:35:04 +0200, Hrvoje Niksic wrote: > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > >> On Thu, 08 May 2008 08:55:35 -0700, krustymonkey wrote: >> >>> The thing is, I'm not using slots by choice. I'm using the standard >>> lib "socket" class, which apparently uses sl

Re: pickle problem

2008-05-08 Thread castironpi
On May 8, 4:35 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > > > On Thu, 08 May 2008 08:55:35 -0700, krustymonkey wrote: > > >> The thing is, I'm not using slots by choice.  I'm using the standard > >> lib "socket" class, which apparently uses

Re: pickle problem

2008-05-08 Thread Hrvoje Niksic
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > On Thu, 08 May 2008 08:55:35 -0700, krustymonkey wrote: > >> The thing is, I'm not using slots by choice. I'm using the standard >> lib "socket" class, which apparently uses slots. > > `socket` objects can't be pickled. Not just because of t

Re: pickle problem

2008-05-08 Thread Marc 'BlackJack' Rintsch
On Thu, 08 May 2008 08:55:35 -0700, krustymonkey wrote: > The thing is, I'm not using slots by choice. I'm using the standard > lib "socket" class, which apparently uses slots. `socket` objects can't be pickled. Not just because of the `__slot__`\s but because a substantial part of their state

Re: pickle problem

2008-05-08 Thread krustymonkey
On May 8, 5:48 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I'm wondering if anyone can help with a workaround for a problem I > > currently have. I'm trying to set up a prefork tcp server. > > Specifically, I'm setting up a server that forks children and has th

Re: pickle problem

2008-05-08 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > I'm wondering if anyone can help with a workaround for a problem I > currently have. I'm trying to set up a prefork tcp server. > Specifically, I'm setting up a server that forks children and has them > listen on pipes created with os.pipe(). The parent process for the

Re: pickle problem

2008-05-07 Thread castironpi
On May 7, 11:02 pm, [EMAIL PROTECTED] wrote: > I'm wondering if anyone can help with a workaround for a problem I > currently have.  I'm trying to set up a prefork tcp server. > Specifically, I'm setting up a server that forks children and has them > listen on pipes created with os.pipe().  The par

Re: Pickle problem

2008-04-21 Thread Mario Ceresa
Dear Jerry and George: it works like a charm! I always thought that the first way was a quicker alternative to defining the init method... shame on me! >From now on I'll read the list every day repeating to myself: "Premature optimization is the root of all evil", "Premature optimization is the ro

Re: Pickle problem

2008-04-18 Thread George Sakkis
On Apr 18, 11:55 am, "Mario Ceresa" <[EMAIL PROTECTED]> wrote: > Hello everybody: > I'd like to use the pickle module to save the state of an object so to > be able to restore it later. The problem is that it holds a list of > other objects, say numbers, and if I modify the list and restore the > o

Re: Pickle problem

2008-04-18 Thread Jerry Hill
On Fri, Apr 18, 2008 at 11:55 AM, Mario Ceresa <[EMAIL PROTECTED]> wrote: > Hello everybody: > I'd like to use the pickle module to save the state of an object so to > be able to restore it later. The problem is that it holds a list of > other objects, say numbers, and if I modify the list and r

Re: Pickle Problem

2007-03-15 Thread 7stud
> I'm trying to make the transition from Java > The biggest thing that was messing me up was the > mandatory "self" input. For some reason I was thinking > that, if I had parenthesis, I would have to define it. I think things are pretty similar in Java. Java does the same thing except 'self' is

Re: Pickle Problem

2007-03-15 Thread Alex Martelli
Gary Herron <[EMAIL PROTECTED]> wrote: ... > fixed, I see another bit of trouble. The pickle format is a binary > format (be default), but you don't open the file in binary mode. On Alas, wish it were:-(. Unfortunately, snipping the right snippet from help(pickle) ...: """ | Th

Re: Pickle Problem

2007-03-15 Thread tonyr1988
On Mar 15, 10:38 am, Gary Herron <[EMAIL PROTECTED]> wrote: > tonyr1988 wrote: > > I'm a complete python n00b writing my first program (or attempting to, > > anyway). I'm trying to make the transition from Java, so if you could > > help me, it would be greatly appreciated. Here's the code I'm stuck

Re: Pickle Problem

2007-03-15 Thread Sönmez Kartal
Hi, You should write your last two lines as ... x = DemoClass() x.WriteToFile() Don't miss paranthesis again... :) Maybe there are still some mistakes too. Does dump method writes list's elements? Sönmez tonyr1988 wrote: > I'm a complete python n00b writing my first program (

Re: Pickle Problem

2007-03-15 Thread Gary Herron
tonyr1988 wrote: > I'm a complete python n00b writing my first program (or attempting to, > anyway). I'm trying to make the transition from Java, so if you could > help me, it would be greatly appreciated. Here's the code I'm stuck on > (It's very basic): > > class DemoClass: > def __init__(s

Re: Pickle Problem

2007-03-15 Thread Jerry Hill
On 15 Mar 2007 08:13:53 -0700, tonyr1988 <[EMAIL PROTECTED]> wrote: > if __name__=='__main__': > x = DemoClass > x.WriteToFile Here, you're binding the Class DemoClass to the name x. What you probably meant to do is create a new instance of DemoClass, and bind that to name x, like

Re: Pickle Problem

2007-03-15 Thread Larry Bates
tonyr1988 wrote: > I'm a complete python n00b writing my first program (or attempting to, > anyway). I'm trying to make the transition from Java, so if you could > help me, it would be greatly appreciated. Here's the code I'm stuck on > (It's very basic): > > class DemoClass: > def __init__(

Re: Pickle Problem

2007-03-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, tonyr1988 wrote: > if __name__=='__main__': > x = DemoClass > x.WriteToFile In Python classes, functions and methods are first class objects. You bind the `DemoClass` class object to the name `x`, you are *not* creating an instance of `DemoClass`. Then you ac

Re: Pickle Problem

2007-03-15 Thread Mike Kent
On Mar 15, 11:13 am, "tonyr1988" <[EMAIL PROTECTED]> wrote: > if __name__=='__main__': > x = DemoClass > x.WriteToFile > You meant to create a DemoClass instance object, but instead, you obtained a reference to the class object. You want 'x = DemoClass()' instead. You meant to ca

Re: pickle problem - frexp() out of range

2007-02-26 Thread Ziga Seilnacht
ahaldar wrote: > Hi: > > I have some large data structure objects in memory, and when I attempt > to pickle them, I get the following error: > > SystemError: frexp() out of range > > Are there some objects that are just too large to serialize, and if > so, is there an easy workaround without breaki

Re: pickle problem - frexp() out of range

2007-02-26 Thread Irmen de Jong
ahaldar wrote: > Hi: > > I have some large data structure objects in memory, and when I attempt > to pickle them, I get the following error: > > SystemError: frexp() out of range > > Are there some objects that are just too large to serialize, and if > so, is there an easy workaround without bre