Writing Object Data to Disk
Bjoern Schliessmann
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Sat Sep 22 05:16:09 EDT 2007
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
More information about the Python-list
mailing list