+ 1
Class based confusion
Class GM: Object={} Class_n='' def __init__(self,name): Gm.Object[Class_n]=self ----------------------------------------- What does this "Gm.Object[Class_n]=self" mean what is self? What will be the Object after this code?
1 Réponse
0
class GM:
Object={}
Class_n=''
def __init__(self,name):
print("self:",self)
print("type of self:",type(self))
GM.Object[GM.Class_n]=self
t = GM("query")
print(GM.Object[''])
#self is GM class instance. GM.Object[GM.Class_n]=self here you are creating dictionary named Object and store the GM instance as value for the key Class_n=''. Try to run above code and get it clarify.