--- [EMAIL PROTECTED] wrote: > > ON = "ON" > OFF = "OFF" > > class LightBulb: > def __init__(self, initial_state): > self.state = initial_state > > def TurnOn(self): > if self.state == OFF: > self.state = ON > else: > print "The Bulb Is Already ON!" > > def TurnOff(self): > if self.state == ON: > self.state = OFF > else: > print "The Bulb Is Aleady OFF!" >
I've written code that looks a lot like that, and it's a perfectly acceptable pattern IMHO. I don't bother with the variables ON and OFF, though, as they add no clarity to simply using 'ON' and 'OFF' for the states. > [...] > The test portion of the code is actually longer than > the class > itself :-) That's usually a good thing! It means your code is concise, and your tests are exhaustive. (But that doesn't mean you can't also refactor your tests.) ____________________________________________________________________________________ Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out. http://answers.yahoo.com/dir/?link=list&sid=396545469 -- http://mail.python.org/mailman/listinfo/python-list