'AttributeError: 'Team' object has no attribute 'jng_player'

import csv
from hashlib import new
class Player:
   def __init__(self, row, header):
        self.__dict__ = dict(zip(header, row))
        
class Team:
  def __init__(self, top_player:Player, mid_player: Player, bot_player: Player, jng_player: Player, sup_player: Player, result: Player, team_id, game_id):
    self.top_player = top_player
    self.mid_player = mid_player
    self.bot_player = bot_player
    self.jng_player = jng_player
    self.sup_player = sup_player
    self.result = self.top_player.result
    self.team_id = self.top_player.team_id
    self.game_id = self.top_player.game_id
    
  def __init__(self) -> None:
      pass
        
class Game:

  def __init__(self, game_id, winnerTeam:Team, loserTeam:Team):
    self.game_id = game_id
    self.winnerTeam = winnerTeam
    self.loserTeam = loserTeam
    
  def __init__(self) -> None:
      pass
    

The Game and Player class works fine but the Team class shows up error when I tried to hit it with print(game.winnerTeam.jng_player.dealths)



Solution 1:[1]

I believe second __init__ in the Team class overwrites the first __init__, so basically Team is a class without any attributes. See also: Multiple constructors in python.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 druskacik