I'd like to know if there's a way to get class instance variables that are inside an init.
I've seen something verify close what I am looking for except that I am looking for a way to get instance variables and not class variables. Linked subject: Looping over class variable's attributes in python
Say I have a class such as:
class Identity:
table = "tb_identity"
def __init__(self, id="", app_name="", app_code="", state="", criticality=""):
self.id = id
self.app_name = trigram_name
self.app_code = trigram_irt
self.state = state
self.criticality = criticality
I'd like to be able to get a list of with instance variables name like:
["id","app_name","app_code","state","criticality"]
With something such as :
members = [getattr(Identity,attr) for attr in dir(Identity) if not attr.startswith("__")]
Im only getting "tb_identity" and not even "table". But that's not the main problem, I am looking for something like:
["id","app_name","app_code","state","criticality"]
Is there any proper way to get these variables inside init ?
Thank you for your time.
Edit: Any way of doing this without instanciation?