dynamically selecting a class to instantiate based on the object attributes.

J. Mwebaze jmwebaze at gmail.com
Wed May 9 07:02:02 EDT 2012


I have a  bunch of objects of the same type. Each object has a version
attribute and this refers to source code that was used to make the object.
SouceCode is maintained in separate files. eg.
myclass_01.py, myclass_02.py, myclass_03.py, myclass_04.py ..

During object instantiaton, i would like to use  the specific class, that
corresponds to the version of the class that was used to create the object.
However i cant know the specific "myclass_??.py" before i read the version
attribute of the object.

Seems like a situation where i have to partially instantiate the object to
read the version attribute, and after that continue with instantiaton with
the specific version of the version..

Is this doeable?
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120509/e83fa558/attachment-0001.html>


More information about the Python-list mailing list