How to properly implement/overload “__repr__ ”?

前端 未结 3 1433
我在风中等你
我在风中等你 2021-01-26 00:27

New to python and this might be a silly question, but how does one properly implement the repr method?

I wrote a quick little program to simulate a game of card

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-26 00:42

    You should return a string type, for example in Deck:

    def __repr__(self):
        ...
        return 'Deck : '+str(self._deck)
    

提交回复
热议问题