Mailing List Archive

pickling and unpickling on the same file?
Is there any way to implement the above beast? Something like:

p = Pickler(file)
u = Unpickler(file)

file.seek(random_pos)
x = u.load()

z = [7, 8, 9]
p.dump(z)

would be perfect
--
Nathan | nathan.froyd@rose-hulman.edu | http://www.rose-hulman.edu/~froydnj/
God went through hell so we don't have to. ICQ:18861764 | AOL:myrlyn007
Avoid the gates of hell. Use Linux. Python:"x='x=%s;x%%`x`';x%`x`"
Evolution is a million line computer program falling into place by accident.
pickling and unpickling on the same file? [ In reply to ]
Have you looked at the shelve module?


----- Original Message -----
From: Nathan Froyd <nathan.froyd@rose-hulman.edu>
Newsgroups: comp.lang.python
To: <python-list@cwi.nl>
Sent: Sunday, April 25, 1999 1:48
Subject: pickling and unpickling on the same file?


> Is there any way to implement the above beast? Something like:
>
> p = Pickler(file)
> u = Unpickler(file)
>
> file.seek(random_pos)
> x = u.load()
>
> z = [7, 8, 9]
> p.dump(z)
>
> would be perfect
> --
> Nathan | nathan.froyd@rose-hulman.edu |
http://www.rose-hulman.edu/~froydnj/
> God went through hell so we don't have to. ICQ:18861764 |
AOL:myrlyn007
> Avoid the gates of hell. Use Linux.
Python:"x='x=%s;x%%`x`';x%`x`"
> Evolution is a million line computer program falling into place by
accident.
>
>
pickling and unpickling on the same file? [ In reply to ]
"Mark Nottingham" <mnot@pobox.com> writes:
> Have you looked at the shelve module?
> > Is there any way to implement the above beast? Something like:
> >
> > p = Pickler(file)
> > u = Unpickler(file)
> >
> > file.seek(random_pos)
> > x = u.load()
> >
> > z = [7, 8, 9]
> > p.dump(z)
> >
> > would be perfect

No, I haven't -- I have to implement a weenie database on my own, and
I thought that anything that interfaced to an already-written database
would not be good. :)

But the point is moot, because the above code does work in my example
file. It didn't work before. I'm not sure what I changed, but I'm
happy that it did!
--
Nathan | nathan.froyd@rose-hulman.edu | http://www.rose-hulman.edu/~froydnj/
God went through hell so we don't have to. ICQ:18861764 | AOL:myrlyn007
Avoid the gates of hell. Use Linux. Python:"x='x=%s;x%%`x`';x%`x`"
Evolution is a million line computer program falling into place by accident.