Feb-26-2019, 08:17 AM
Python forum
I am looking for a way to dynamically define class's.
my motivation is to define a material library for my company that will be updated through excel periodically by other people. the library will be changing, such that available materials will be different, prices will be different, properties will change,....
I want my objects to reflect the updated version of this database.
I want to import the excel database using pandas data frame, and then generate class's with attributes driven from the database.
there is alot of information regarding metaclass's or how to define class's using the type function, however this won't help me, because the init function must still be fully defined out of the type function class generation statment.
this doesn't really help me because in addition I don't know how to dynamically define functions.
its a bit weird, the internet considers this topic isoteric, like its just a deep pythonism that isn't practical, however, I don't understand why everyone doesn't program like this.
anyways, please help,
regards,
I am looking for a way to dynamically define class's.
my motivation is to define a material library for my company that will be updated through excel periodically by other people. the library will be changing, such that available materials will be different, prices will be different, properties will change,....
I want my objects to reflect the updated version of this database.
I want to import the excel database using pandas data frame, and then generate class's with attributes driven from the database.
there is alot of information regarding metaclass's or how to define class's using the type function, however this won't help me, because the init function must still be fully defined out of the type function class generation statment.
this doesn't really help me because in addition I don't know how to dynamically define functions.
its a bit weird, the internet considers this topic isoteric, like its just a deep pythonism that isn't practical, however, I don't understand why everyone doesn't program like this.
anyways, please help,
regards,