On Tue, Apr 24, 2012 at 1:02 AM, J. Mwebaze <jmweb...@gmail.com> wrote: > We have classes of this form classA version1, classA version2, classA > version3 .. etc. This is same class that has been modified. Each > "modification" creates a new version of a class. Each object has a version > attribute which refers to the version of the class from which it was > derived. egObjectA.version =1 # means it was derived from ClassA version1
Note that each object already has a __class__ attribute containing the class it is an instance of, so unless you have special need of version number metadata, it may not be necessary. > Here is my problem. During object de-serializing, i would like to use the > specific version of the class that was used to used to make the object. For > example, if i am de-serializing object ObjectA withversion=3 then ClassA > version 3 should be used. Source code for all the different variations of > the classes is stored. What serialization scheme are you using, and how are the classes stored? If you're using pickle and you keep them accessible from the module they were defined in using the name they were defined with, then you won't need to do anything special here -- pickle will look up that name in that module and find the class. If you're doing something more creative, then you'll want to override the __reduce__ method in your classes to pass in a custom constructor that takes into account the version number. -- http://mail.python.org/mailman/listinfo/python-list