[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Python enumerations
While thinking about the problem, it occured to me that that classes
could also be used as enumerations - not class names, but the actual
object representing a class, like this:
class Apple:
def onEat(self): print 'Ate an apple.'
class Peach:
def onEat(self): print 'Ate a peach.'
preferedFruit = Peach
if preferedFruit == Peach: print 'We like peaches.'
fruit = preferedFruit() # Create a new instance.
fruit.onEat()
--
The evidence in support of [global cooling] has now begun to
accumulate so massively that meteorologists are hard-pressed to
keep up with it. In England, farmers have seen their growing
season decline by about two weeks since 1950...
- Newsweek, 28 April 1975, p. 64