When I'm trying to append()
the object itself into a list inside the object, it doesn't work, I don't understand why.
class PLayer:
CLASS_NAME = "player"
TOTAL_PLAYER_NUMBER = 0
TOTAL_PLAYER_LIST = []
PLAYER_ID_INCREMENT = 0
def __init__(self, name,
first_name,
birthday,
note,
player_id=None,
total_score=None,
tournament_score=None):
self.PLAYER_ID_INCREMENT += 1
self.TOTAL_PLAYER_NUMBER += 1
self.name = name
self.first_name = first_name
self.birthday = birthday
self.player_id = self.PLAYER_ID_INCREMENT
self.total_score = 0
self.tournament_score = 0
self.note = note
self.TOTAL_PLAYER_LIST.append(self.Player)
So the class Player have a list TOTAL_PLAYER_LIST = []
, then inside the __init__
I want to add the player that have been freshly created to the list with the last line self.TOTAL_PLAYER_LIST.append(self.Player)
but I get this error
line 25, in __init__
self.TOTAL_PLAYER_LIST.append(self.Player)
AttributeError: 'PLayer' object has no attribute 'Player'
I don't understand why. I've tried to put and remove self.
, the parenthesis also () for Player() .