The Artima Developer Community
Sponsored Link

Python Buzz Forum
My brain and pickle don't mix

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jarno Virtanen

Posts: 109
Nickname: jajvirta
Registered: May, 2003

Jarno Virtanen is a university student for life, it seems, and a part time software developer
My brain and pickle don't mix Posted: Jul 17, 2003 6:33 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Jarno Virtanen.
Original Post: My brain and pickle don't mix
Feed Title: Python owns us
Feed URL: http://sedoparking.com/search/registrar.php?domain=®istrar=sedopark
Feed Description: A weblog about Python from the view point of Jarno Virtanen.
Latest Python Buzz Posts
Latest Python Buzz Posts by Jarno Virtanen
Latest Posts From Python owns us

Advertisement

There is something deeply wrong in my brain. I just cannot, for the life of me, remember the correct order of arguments for pickle.dump(). Just few minutes ago, I wrote these lines in order to test whether I could get it right this time:

import pickle 
data = {'foo': 1, 'baz': 2} 
handle = open('test.pickle', 'w') 
pickle.dump(handle, data) 
Right? No. Wrong, wrong, wrong.
Traceback (most recent call last):
  File "", line 9, in ?
  File "/usr/lib/python2.2/pickle.py", line 974, in dump
    Pickler(file, bin).dump(object)
  File "/usr/lib/python2.2/pickle.py", line 110, in __init__
    self.write = file.write
AttributeError: 'dict' object has no attribute 'write'
Thank you for reminding me.

What is wrong with me? Sure, I don't use pickle all the time, but I've done this mistake so many times that I should already have learned it. But no. I once even tried to intentionally write it wrong, so that I would actually write it right, but that didn't work out either.

Maybe I need to assign the following for some command line alias:

python -c "import cPickle; print cPickle.dump.__doc__"
(I wonder if the plain pickle module should contain the docstrings too. Don't know.)

Anyhow, I just wanted to share this. Thank you for your attention.

Read: My brain and pickle don't mix

Topic: A backup script for spambayes Previous Topic   Next Topic Topic: New stuff

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use