Pickle class instance

I’d like to pickle a class instance, but this simple test code fails with the following message:

pickle.PicklingError: Can’t pickle <class ‘main.Foo’>: it’s not found as main.Foo

Suggestions welcomed.

#!BPY 
import pickle 
class Foo(object): 
    def __init__(self): 
        self.one = 1 
foo = Foo() 
p = pickle.dumps(foo) 
print p 

Answer found. Blender prefers old style classes. Changing ‘class Foo(object)’ to simply ‘class Foo’ eliminated the error.

#!BPY 
import pickle 
class Foo: 
    def __init__(self): 
        self.one = 1 
foo = Foo() 
p = pickle.dumps(foo) 
print p