How to dynamically initialize a variable according to the object’s creating method in python?
class obj(object): def __init__(self): self.name = … # How to set this variable dynaically by using the variable name (on create) or the object name? var = obj() print(var.name) # prints “var” (assigned variable name) print(obj().name) # prints “obj” Currently, both of them prints “obj”. How can I set self.name according to the way the […]