Python class variables or a dict?

Hi all,

So here's an OOP design question.

Let's say I have a class Player, and this player has class variables

  • name
  • action_1_name
  • action_2_name
  • alive status
  • health
  • etc.

with the appropriate setters and getters.

Is it better or more clean to have several variables for this class to hold these values, or to put them all into a single dict such as self.stats = {'health':100, 'name':'Gary Motherfucking Oak'} etc. ?

(Note: this class will have several subclasses later on.)

Posted Sep 16, 2015, 6:39 AM UTC · edited

2412
Loading comments…