+ 1

checking object name without an attribute

hey there! look at the code: class myclass: def __init__(self,name): self.name=name def do(self): if self.name='x' print('x') object=myclass('object') ########## in function 'do' i checked a condition: if the object name is x, do something. but the object.name=object so i think it should be possible to check the object name without an attribute. like replacing 'if self.name' with 'if self'. how can i do this? so that i can use object=myclass() instead of object=myclass('object')

2nd Dec 2017, 1:31 PM
Aref moloughi
Aref moloughi - avatar
1 Odpowiedź
0
your question is very confusing to me I might be better able to answer if I see proper code. sorry
4th Dec 2017, 2:54 AM
Kevin Oudai
Kevin Oudai - avatar