简体   繁体   中英

AttributeError: <Class> object has no attribute

I have this class:

class MyManager():

    def __init__(self):
        self.__sock_service = ClientSocket()

    def say_hello(self, request: Dict):
        self.__sock_service.send(request['name'])
        return self.__sock_service.receive()

When calling say_hello method, I get

"AttributeError: MyManager object has no attribute __sock_service". 

Though, I do have an object _MyManager.__sock_service that is initialized (plus, my server does recognize a new connection).

What am I doing wrong?

Is this the full code? If not please write the full code

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM