views:

46

answers:

2

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"))        
A: 

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.

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

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.

LaserDude11
Yeah, It works!
LaserDude11