Hi,
is it possible in python (with/without matplotlib, numpy etc) to store
a whole class with its data into a file, instead it to reconstruct
every time again? So is there an analogous to the matlab functions
load/save available?
Thanks
Alex 7 1851
is it possible in python (with/without matplotlib, numpy etc) to store
a whole class with its data into a file, instead it to reconstruct
every time again? So is there an analogous to the matlab functions
load/save available?
look up the pickle module. al******@googlemail.com enlightened us with:
is it possible in python (with/without matplotlib, numpy etc) to
store a whole class with its data into a file
Check out the pickle module.
Sybren
--
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/
Hi,
thanks for the reply,but unfortunately this does not work with the type
of classes I am dealing with. When trying to pickle the class I get the
following error:
File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex
raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__
cannot be pickled
So there is something missing in this class? Or any other idea how to
do this?
Alex
Sybren Stuvel wrote:
al******@googlemail.com enlightened us with:
is it possible in python (with/without matplotlib, numpy etc) to
store a whole class with its data into a file
Check out the pickle module.
Sybren
--
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/ al******@googlemail.com wrote:
thanks for the reply,but unfortunately this does not work with the type
of classes I am dealing with. When trying to pickle the class I get the
following error:
File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex
raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__
cannot be pickled
So there is something missing in this class?
did you remember to read the error message before posting ?
</F> al******@googlemail.com wrote:
Hi,
thanks for the reply,but unfortunately this does not work with the type
of classes I am dealing with. When trying to pickle the class I get the
following error:
File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex
raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__
cannot be pickled
So there is something missing in this class? Or any other idea how to
do this?
Alex
yes, read the documentation: http://docs.python.org/dev/lib/pickle-inst.html
Michele Simionato
Hi,
Fredrik Lundh wrote: al******@googlemail.com wrote:
thanks for the reply,but unfortunately this does not work with the type
of classes I am dealing with. When trying to pickle the class I get the
following error:
File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex
raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__
cannot be pickled
So there is something missing in this class?
did you remember to read the error message before posting ?
of course I read the error-message, I understand the error-message, BUT
this message is not telling me how anyway to save the data of such a
class in a file! It does not tell me, that there is absolutely no way
to do that. Maybe there is, maybe there is not.
Thats why I am posting it here!
Alex
At Wednesday 25/10/2006 11:32, al******@googlemail.com wrote:
>Fredrik Lundh wrote:
al******@googlemail.com wrote:
thanks for the reply,but unfortunately this does not work with the type
of classes I am dealing with. When trying to pickle the class I get the
following error:
>
File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex
raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__
cannot be pickled
>
So there is something missing in this class?
did you remember to read the error message before posting ?
of course I read the error-message, I understand the error-message, BUT this message is not telling me how anyway to save the data of such a class in a file! It does not tell me, that there is absolutely no way to do that. Maybe there is, maybe there is not. Thats why I am posting it here!
"A man who wears a hat without buying a ticket cannot enter the theatre"
You wear a hat, you want to enter: either buy your ticket or forget
about your hat.
In this case, just define a __getstate__ method (read the pickle
docs), or forget about __slots__.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Krzysztof Stachlewski |
last post by:
I tried to run the following piece of code:
Python 2.3.4 (#53, May 25 2004, 21:17:02) on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> o = object()
>>> o.a...
|
by: Andreas Palsgård |
last post by:
Hey.. i want to write a class object containing both strings and integers,
to a file on disk, and be able to read it properly again at another time. I
made the code below... it doesn't work, but...
|
by: surrealtrauma |
last post by:
the requirement is :
Create a class called Rational (rational.h) for performing arithmetic with
fractions. Write a program to test your class.
Use Integer variables to represent the private data...
|
by: ypjofficial |
last post by:
Dear All,
According to OOPs , a base class pointer can to point to derived class
object....call this as fact1
But somehow I am not comfortable while understanding this concept.
The explanaition...
|
by: Les Coover |
last post by:
The following is an example of input:
1 Les
L 01/02/04 2300 06:00AM SW Nashville
R 01/06/04 2400 10:00PM SW Kansas City
L 01/15/04 2440 10:00AM NW Minneapolis
R 01/15/04 3440 05:00PM NW...
|
by: monsieur.marco |
last post by:
Hi all,
Does anybody know how to save localization in an excel workbook (C#
1.1)? I'm not sure this is possible, but I'm trying to do this so that
numberColumns keep their format no matter what...
|
by: wanwan |
last post by:
when I program with Java, I'm able to open a file to open a file
stream and an object stream, then save a class object into a file.
I don't see any class in vb.net that is equivalent to object...
|
by: ganeshshegde |
last post by:
Hi..
Can we store whole file in database? ie it should store in database in same format. .pdf should store in .pdf fomat and .doc should store in .doc fomat.
|
by: hanna88 |
last post by:
hello..
is there a way of storing data to other class object.
here's the problem.
class Repository is where it reads through the sentences and tokenize it
into words . and what i did is by using...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
| |