0

I have a problem trying to unpickle subclasses of this class. When I unpickle it, the stuff isn't there. What gives? class Account:

    def __init__(self, server, port, smtp_server, smtp_port):
        self.server = server
        self.port = port
        self.smtp_server = smtp_server
        self.smtp_port = smtp_port

        self.save()

    def save(self):
        #save account for later loading
        self.name = tkFileDialog.asksaveasfilename(title = "Save as..")
        pickle.dump(self, open(self.name, "wr"))        
1
  • Oh, yeah, the unpickling part is in the same module that this is in, and is called from another module. Yeah, I know it's bad. Commented Jul 16, 2010 at 13:58

2 Answers 2

1

Does your class inherit object?

Either way, you can specify what you want to pickle by overwriting __getstate__. Otherwise it should normally copy __dict__ if you're inheriting object.

Sign up to request clarification or add additional context in comments.

3 Comments

Ok. I thought it was a given. I'll try that, thanks. Usually, python knows what I like...
No, it didn't work. It still says that it's a nonetype, and doesen't have attributes...
So... is it working now? And if not, what class are you inheriting?
0

So, Here's how I just figured it out- i moved the ugly pickle stuff (see comment) to the unpickling class, imported the classes I was pickling, and it seems like it works.

2 Comments

nice that you worked it out, but if you had posted the solution here, other people could have benefit from it.
I'm actually not sure where that stuff is now, since I stopped using pickle in favor of other forms of serialization.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.