[Tutor] making a list of a custom object

Kate Reeher madecunningly at outlook.com
Fri Sep 19 23:25:50 CEST 2014


I have a custom class called Game, and it has a variable called "goals". I'd like to make this a list of custom objects, with various information about the goals.
class Game:	goals = {}	class Goal(object):	def __init__(self,time,goal_by,assist_by,team,is_powerplay ):			self.time=time			self.goal_by=goal_by			self.assist_by=assist_by			self.team=team			self.is_powerplay=is_powerplay

Is that Goal class set up correctly? 
For an instance of Game called game, is this how you'd set a variable of a goal?game.goals[i].time= time 

I'm finding how python does data classes INCREDIBLY confusing, for whatever reason, so any help would be appreciated.
Thanks,Kate
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140919/7cb3a908/attachment.html>


More information about the Tutor mailing list