title: Grouping constants in python
body: <p>This is mainly a "good python style" question.</p>
  
  <p>I have a module which is using a number of constants that feels should be grouped. </p>
  
  <p>Lets say we have Dogs and cat and each of them have number of legs and favorite food. </p>
  
  <p>Note that </p>
  
  <ol>
  <li>we want to model nothing but those constants about Dogs and Cats</li>
  <li>quite probably we'll have more animals in the future.</li>
  <li>those constants wont be used outside of the current module.</li>
  </ol>
  
  <p>I thought about the following solutions:</p>
  
  <hr>
  
  <p>Constants at  module level</p>
  
  <pre><code>DOG_NUMBER_OF_LEGS = 4
  DOG_FAVOURITE_FOOD = ["Socks", "Meat"]
  CAT_NUMBER_OF_LEGS = 4
  CAT_FAVOURITE_FOOD = ["Lasagna", "Fish"]
  </code></pre>
  
  <p>They seem not really grouped, but I think it is the solution I prefer.</p>
  
  <hr>
  
  <p>Classes as namespaces</p>
  
  <pre><code>class Dog(object):
    NUMBER_OF_LEGS = 4
    DOG_FAVOURITE_FOOD = ["Socks", "Meat"]
  class Cat(object):
    NUMBER_OF_LEGS = 4
    FAVOURITE_FOOD = ["Lasagna", "Fish"]
  </code></pre>
  
  <p>I don't like this solution as we'll have class that we wont use and they can be actually instantiated.</p>
  
  <hr>
  
  <p>Dictionary of constants</p>
  
  <pre><code>ANIMALS_CONFIG = { 
     "DOG" : { 
       "NUMBER_OF_LEGS" : 4,
       "FAVOURITE_FOOD" : ["Socks", "Meat"]
     },
     "CAT" : { 
       "NUMBER_OF_LEGS" : 4,
       "FAVOURITE_FOOD" : ["Lasagna", "Fish"]
     }
  }
  </code></pre>
  
  <hr>
  
  <p>I also thought about adding submodules but I dont really want to expose those internal constants</p>
  
  <hr>
  
  <p>what is the most pythonic way to do it / how would you do it?</p>