Hello,
I have a Python class with data members, say:
class Foo:
def __init__(self):
self.a=7
self.b[]={1,3,4}
#couple of more lists, tuples, etc
I would like to know if "Pickling" the class object is the only way of
writing it to disk for persistent storage. Also, do we have a concept
similar to "array of objects" in Python? The number of objects is only
known at "run-time".
Thanks,
--
Amit Kumar Saha
me blogs@ http://amitksaha.blogspot.com
URL: http://amitsaha.in.googlepages.com 3 1591
In message <ma************ *************** **********@pyth on.org>, Amit Kumar
Saha wrote:
I would like to know if "Pickling" the class object is the only way of
writing it to disk for persistent storage.
Wouldn't it be better to use a language-independent data representation that
wasn't tied to Python? Also tying your external data representation to your
internal program structure (objects) makes it harder to change the program
in future.
Amit Kumar Saha wrote:
I have a Python class with data members, say:
class Foo:
def __init__(self):
self.a=7
self.b[]={1,3,4}
^^
This is invalid syntax.
I would like to know if "Pickling" the class object is the only
way of writing it to disk for persistent storage.
It isn't. Every means of serialisation works, but pickling is
especially convenient if you only use Python.
Also, do we have a concept similar to "array of objects" in
Python?
You can put all objects in lists, be it a string, an integer or some
complex class instance.
The number of objects is only known at "run-time".
class and function definitions also happen at runtime. I suggest you
worked through the Python tutorial to get a deeper insight in
Python's concepts. http://docs.python.org/tut/
Regards,
Björn
--
BOFH excuse #89:
Electromagnetic energy loss
On 22/09/2007 7:16 PM, Bjoern Schliessmann wrote:
Amit Kumar Saha wrote:
>I have a Python class with data members, say:
class Foo: def __init__(self):
self.a=7 self.b[]={1,3,4}
^^
This is invalid syntax.
So are the braces. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joseph |
last post by:
Hi
I'm writing a commercial program which must be reliable. It has to do
some basic reading and writing to and from files on the hard disk,
and also to a floppy.
I have foreseen a potential problem. The program may crash
unexpectedly while writing to the file. If so, my program should
detect this during startup, and then (during startup) probably delete the
data added to the file and redo the writing operation.
|
by: Lu |
last post by:
Hi there,
I got a program to write data to a randomly accessed file (the program
moves file pointer to a certain position of the file according the
current "keyword" and then writes data). It compiles and runs in Win2K
and various Unix and Linux systems. The main program is in Fortran,
calling a data writing library writen in C++.
The weird thing is, it takes much longer elapse time (wall-clock time)
than CPU time (e.g., 20 min vs. 2...
|
by: Ben Jeurissen |
last post by:
Hello,
I have to deal with the following issue in C++:
Two threads are started from the main thread, both capturing images from
a different firewire camera. Both threads take shots of 460800 bytes at
a rate of 30 frames per second. This works fine, without frame loss, and
I can display the two framestreams on screen.
Now I would like to write these frames to my disk too (2 10000rpm in
|
by: ishekar |
last post by:
Hi,
I have an application where i want to write data to a file, the data is
being sent from an external source. I know the total size of the data and
then i retrieve the data in small segments from the source. This data is
written to file in a loop.
My question.
1. Will it be useful to increase the file size initially then seek to 0 and
start writing to file. whether there will be any performance improvements
|
by: Virendra Verma |
last post by:
This sounds weird, but I am looking for separate behaviors for
destruction of a const and non-const object.
I am trying to develop a smart/auto pointer class for writing objects
to disk implicitly. The destructor of this class saves the object to
the disk if it is dirty. The problem comes in the following scenario
when a function returns an uncommitted pointer class because same
copies will be committed as two separate objects on disk....
| |
by: Ali |
last post by:
Hi
I want to write (or read) to a stream, but the data is not byte array
I converted the data to byte array manually, but it is very slow, (becuse the data is very large)
Is another way for this kind of writing and reading
best regard
Ali.
|
by: melanieab |
last post by:
Hi,
I'm trying to store all of my data into one file (there're about 140 things
to keep track of). I have no problem reading a specific string from the
array file, but I wasn't sure how to replace just one item. I know I can get
the entire array, then save the whole thing (with a for loop and if
statements so that the changed data will be saved), but it seems like a lot
of unnecessary reading and writing. Is there a way to directly save...
|
by: Chris Springer |
last post by:
I'd like to get some feedback on the issue of storing data out to disk and
where to store it. I've never been in a production environment in
programming so you'll have to bear with me...
My question is about storing data in a database. Yes I understand that you
can link to a database in your program and read and write to the database
etc etc. Well, that's all find and dandy but what if the person you're
writing the application for...
|
by: Claudio Grondi |
last post by:
I have a 250 Gbyte file (occupies the whole hard drive space) and want
to change only eight bytes in this file at a given offset of appr. 200
Gbyte (all other data in that file should remain unchanged).
How can I do that in Python?
Claudio Grondi
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |