怎样在定义一个对象的时候取得对象的名称,例如:
class TheThing(): def __init__(self): self.name = str(self) #此处想获得赋值对象的名称 print(self.name) a = TheThing()
此时想要得到a.name==’a’,该如何实现
光阴似箭催人老,日月如移越少年。
It cannot be implemented because TheThing() will be executed first to obtain an instance of TheThing, and then a will be pointed to this instance. a is just a yin and yang. When executing "a=", TheThing's __init__ has already been executed
It cannot be implemented because TheThing() will be executed first to obtain an instance of TheThing, and then a will be pointed to this instance. a is just a yin and yang. When executing "a=", TheThing's __init__ has already been executed