I have a an if check that uses has.key:
if self.has_key(observer.key):
and i am trying to replace it to use the in
keyword.
I have tried doing:
if observer.key in self:
#
if observer.key in self.__dict__:
But neither of them work returning:
E TypeError: argument of type 'Observers' is not iterable
The class had a has_key method deep inside, which did this functionality but i assume pycharm though it was the builtin method:
def has_key(self, key):
return key in self.keys
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.