I am doing a project centered around OOP and started wondering: Is there a difference between this?
class Trainer:
def __init__(self, name):
self.name = name
self.potions = 10
self.bag = list()
self.team = list()
self.current_poke = self.team[0]
as opposed to doing this:
class Trainer:
def __init__(self, name, potions, bag, team, current_poke):
self.name = name
self.potions = potions
self.bag = bag
self.team = team
self.current_poke = current_poke
Is one version better than the other, and if so why. I know that one allows you to define more specific values for each variable each time you instantiate an object. But are there any operational/efficiency differences between the two?
self.team[0]will get an error, sinceself.teamis empty. - Barmar