On 08/06/2013 04:00 PM, Ian Kelly wrote:

Use the .value attribute instead.  You could also substitute self for 
Environment.


class Environment(Enum):

     gaia = 1
     fertile = 2
     terran, jungle, ocean, arid, steppe, desert, minimal = range(3, 10)
     barren, tundra, dead, inferno, toxic, radiated = range(10, 16)

     def is_standard(self):
         return self.terran.value <= self.value <= self.minimal.value

     def is_hostile(self):
         return self.barren.value <= self.value

     @property
     def growth_factor(self):
         if self.is_standard():
             return 1.0
         elif self.is_hostile():
             return 0.5
         elif self is self.fertile:
             return 1.5
         elif self is self.gaia:
             return 2.0
         else:
             raise AttributeError("Unknown growth_factor for %s" % self)

--
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to