title: Pickling error : Can't pickle <class 'Player.Player'>: it's not the same object as Player.Player
body: <p>Sorry if this question has been asked before, I've seen similar and responses were saying to fiddle with inputs, but I have been trying to adjust for awhile to no success. Here is how my code is written</p>
  <pre><code>import Player
  import API
  import pickle
  class PlayerList:
      def __init__(self):
          self.NUMPLAYERS = len(API.getGeneral()['elements'])
          self.players = [None]*self.NUMPLAYERS
          for p in range(self.NUMPLAYERS):
              player = API.getPlayer(p+1)
              player_data = API.getPlayerData(p+1)
              self.players[p]=Player.Player(player,player_data)
              left = self.NUMPLAYERS-p
              if left%100==0:
                  print(left, &quot; leftover&quot;)
      def saveAsPickle(self,fname):
          with open(fname, 'wb') as outp:
                  pickle.dump(self, outp, pickle.HIGHEST_PROTOCOL)
  </code></pre>
  <p>The Player file is written as</p>
  <pre><code>from Fixture import Fixture
  import API
  import Team
  
  class Player:
      def __init__(self,player,player_data):
          self.id = player['id']
          self.first_name = player['first_name']
          self.last_name = player['second_name']
          self.positionType = player['element_type']
          teamID = player['team']
          self.team = Team.Team(API.getTeam(teamID))
          self.influence = player['influence']
          self.creativity = player['creativity']
          self.threat = player['threat']
          self.penalties = player['penalties_order']
          self.freekicks = player['direct_freekicks_order']
          self.corners = player['corners_and_indirect_freekicks_order']
          self.totalGoals = player['goals_scored']
          self.totalAssists = player['assists']
          self.totalCleanSheets = player['clean_sheets']
          self.totalOwnGoals = player['own_goals']
          self.totalPenaltiesMissed = player['penalties_missed']
          self.totalPenaltiesSaved = player['penalties_saved']
          self.totalSaves = player['saves']
          self.totalYellows = player['yellow_cards']
          self.totalReds = player['red_cards']
          self.totalBps = player['bps']
          self.totalBonus = player['bonus']
          self.totalMinutes = player['minutes']
          hist = player_data['history']
          numFixtures = len(hist)
          self.fixtures = [None]*numFixtures
          for f in range(numFixtures):
              fixture = hist[f]
              self.fixtures[f]=Fixture(fixture)
  </code></pre>
  <p>When I try to use the saveAsPickle method I always get that error, what am I doing wrong here? I have tried both import Player and then calling Player.Player, as well as importing Player from Player.</p>