Re: A pickle problem!

2016-04-24 Thread Fabien
On 04/21/2016 11:43 PM, Paulo da Silva wrote: class C(pd.DataFrame): Note also that subclassing pandas is not always encouraged: http://pandas.pydata.org/pandas-docs/stable/internals.html#subclassing-pandas-data-structures Cheers, Fabien --

Re: A pickle problem!

2016-04-22 Thread Paulo da Silva
Às 21:33 de 22-04-2016, Ian Kelly escreveu: > On Fri, Apr 22, 2016 at 2:21 PM, Paulo da Silva > wrote: ... > > If they start with two underscores then you could use the name > mangling to find them. If the class name is MyClass then look for any > keys in the

Re: A pickle problem!

2016-04-22 Thread Ian Kelly
On Fri, Apr 22, 2016 at 2:21 PM, Paulo da Silva wrote: > Às 17:27 de 22-04-2016, Ian Kelly escreveu: >> On Thu, Apr 21, 2016 at 7:52 PM, Paulo da Silva >> wrote: >>> Às 22:43 de 21-04-2016, Paulo da Silva escreveu: > ... > >> >>

Re: A pickle problem!

2016-04-22 Thread Paulo da Silva
Às 17:27 de 22-04-2016, Ian Kelly escreveu: > On Thu, Apr 21, 2016 at 7:52 PM, Paulo da Silva > wrote: >> Às 22:43 de 21-04-2016, Paulo da Silva escreveu: ... > > Probably this is necessary because the DataFrame class is already > customizing its pickle behavior

Re: A pickle problem!

2016-04-22 Thread Ian Kelly
On Thu, Apr 21, 2016 at 7:52 PM, Paulo da Silva wrote: > Às 22:43 de 21-04-2016, Paulo da Silva escreveu: >> Hi. >> >> Why in this code fragment self.__name is not kept between pickle >> dumps/loads? How to fix it? >> >> Thanks. >> >> import pickle >> import

Re: A pickle problem!

2016-04-21 Thread Paulo da Silva
Às 22:43 de 21-04-2016, Paulo da Silva escreveu: > Hi. > > Why in this code fragment self.__name is not kept between pickle > dumps/loads? How to fix it? > > Thanks. > > import pickle > import pandas as pd > import numpy as np > > class C(pd.DataFrame): > def __init__(self,name,*a,**b):

A pickle problem!

2016-04-21 Thread Paulo da Silva
Hi. Why in this code fragment self.__name is not kept between pickle dumps/loads? How to fix it? Thanks. import pickle import pandas as pd import numpy as np class C(pd.DataFrame): def __init__(self,name,*a,**b): super(C,self).__init__(*a,**b)

Re: Pickle problem while loading a class instance.

2010-04-09 Thread gerardob
this message in context: http://old.nabble.com/Pickle-problem-while-loading-a-class-instance.-tp28154964p28197881.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickle problem while loading a class instance.

2010-04-09 Thread Gabriel Genellina
En Fri, 09 Apr 2010 18:42:23 -0300, gerardob gberbeg...@gmail.com 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?

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 script

Pickle problem while loading a class instance.

2010-04-06 Thread gerardob
1090, in load_global klass = self.find_class(module, name) File C:\Python26\lib\pickle.py, line 1124, in find_class __import__(module) ImportError: No module named markov_model -- View this message in context: http://old.nabble.com/Pickle-problem-while-loading-a-class-instance.-tp28154964p28154964

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 =

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

2009-03-05 Thread Fab86
On Mar 4, 2:49 pm, MRAB goo...@mrabarnett.plus.com wrote: Fab86 wrote: On Mar 4, 1:40 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 23:11:30 -0200, Fab86 fabien.h...@gmail.com escribió: On Mar 4, 12:00 am, MRAB goo...@mrabarnett.plus.com wrote: Fab86 wrote: On

Re: Pickle Problem

2009-03-05 Thread MRAB
Fab86 wrote: On Mar 4, 2:49 pm, MRAB goo...@mrabarnett.plus.com wrote: Fab86 wrote: On Mar 4, 1:40 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 23:11:30 -0200, Fab86 fabien.h...@gmail.com escribió: On Mar 4, 12:00 am, MRAB goo...@mrabarnett.plus.com wrote: Fab86

Re: Pickle Problem

2009-03-04 Thread Fab86
On Mar 4, 1:40 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 23:11:30 -0200, Fab86 fabien.h...@gmail.com escribió: On Mar 4, 12:00 am, MRAB goo...@mrabarnett.plus.com wrote: Fab86 wrote: On Mar 3, 8:59 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: How

Re: Pickle Problem

2009-03-04 Thread MRAB
Fab86 wrote: On Mar 4, 1:40 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 23:11:30 -0200, Fab86 fabien.h...@gmail.com escribió: On Mar 4, 12:00 am, MRAB goo...@mrabarnett.plus.com wrote: Fab86 wrote: On Mar 3, 8:59 pm, Gabriel Genellina gagsl-...@yahoo.com.ar

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

Pickle Problem

2009-03-03 Thread Fab86
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(res2.total_results_available,file)

Re: Pickle Problem

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 1:52 AM, Fab86 fabien.h...@gmail.com 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)

Re: Pickle Problem

2009-03-03 Thread Fab86
On Mar 3, 10:34 am, Chris Rebert c...@rebertia.com wrote: On Tue, Mar 3, 2009 at 1:52 AM, Fab86 fabien.h...@gmail.com 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 =

Re: Pickle Problem

2009-03-03 Thread Hrvoje Niksic
Fab86 fabien.h...@gmail.com 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

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 =

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') print f, 123

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 and...@acooke.org 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

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:00 

Re: Pickle Problem

2009-03-03 Thread odeits
On Mar 3, 4:16 am, Fab86 fabien.h...@gmail.com 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,

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_available

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

Re: Pickle Problem

2009-03-03 Thread Fab86
On Mar 3, 1:02 pm, MRAB goo...@mrabarnett.plus.com 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 =

Re: Pickle Problem

2009-03-03 Thread Gabriel Genellina
En Tue, 03 Mar 2009 16:39:43 -0200, Fab86 fabien.h...@gmail.com 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

Re: Pickle Problem

2009-03-03 Thread Fab86
On Mar 3, 6:48 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 16:39:43 -0200, Fab86 fabien.h...@gmail.com 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

Re: Pickle Problem

2009-03-03 Thread Gabriel Genellina
En Tue, 03 Mar 2009 16:50:25 -0200, Fab86 fabien.h...@gmail.com escribió: On Mar 3, 6:48 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 16:39:43 -0200, Fab86 fabien.h...@gmail.com escribió: I am having a bit on an issue getting my program to work. The online

Re: Pickle Problem

2009-03-03 Thread Fab86
On Mar 3, 8:59 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 16:50:25 -0200, Fab86 fabien.h...@gmail.com escribió: On Mar 3, 6:48 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 16:39:43 -0200, Fab86 fabien.h...@gmail.com   escribió:

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 module except SearchError: NameError: name 'SearchError' is

Re: Pickle Problem

2009-03-03 Thread MRAB
Fab86 wrote: On Mar 3, 8:59 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 16:50:25 -0200, Fab86 fabien.h...@gmail.com escribió: On Mar 3, 6:48 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 16:39:43 -0200, Fab86 fabien.h...@gmail.com

Re: Pickle Problem

2009-03-03 Thread Fab86
On Mar 4, 12:00 am, MRAB goo...@mrabarnett.plus.com wrote: Fab86 wrote: On Mar 3, 8:59 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 03 Mar 2009 16:50:25 -0200, Fab86 fabien.h...@gmail.com escribió: On Mar 3, 6:48 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue,

Re: Pickle Problem

2009-03-03 Thread Gabriel Genellina
En Tue, 03 Mar 2009 23:11:30 -0200, Fab86 fabien.h...@gmail.com escribió: On Mar 4, 12:00 am, MRAB goo...@mrabarnett.plus.com wrote: Fab86 wrote: On Mar 3, 8:59 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: How to spell exactly the exception name should appear in the  

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 the standard lib

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: The thing is, I'm not

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 communication,

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-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 them

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 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 the

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 slots.

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 slots. `socket`

pickle problem

2008-05-07 Thread krustymonkey
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 group starts an inet:tcp server

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 parent

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 root

Pickle problem

2008-04-18 Thread Mario Ceresa
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 object, the list itself is not reverted to the saved one, but stays with

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

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 object,

Pickle problem

2008-01-02 Thread Daniel Cuschieri
Hi, I used code similar to the one at http://www.onlamp.com/pub/a/python/2006/02/09/ai_decision_trees.html in order to build an ID3 decision tree using python. I obviously do not want to rebuild this tree every time i need to use it! so i tried to save it using pickle, after building it: from

Pickle Problem

2007-03-15 Thread tonyr1988
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__(self):

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 call the

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 access

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__(self):

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 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__(self):

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 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 on

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) ...: | The

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

pickle problem - frexp() out of range

2007-02-26 Thread ahaldar
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 breaking up the object and

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 breaking up

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 breaking up