Travis Griggs travisgriggs at
Thu Oct 9 07:38:26 CEST 2014

On Oct 8, 2014, at 9:57 PM, Gregory Ewing <greg.ewing at> wrote:

> Seymore4Head wrote:
>> I want to toggle between color="Red" and color="Blue"

Don’t forget polymorphic dispatch…

class Red(object):
    def toggle(self):
        return Blue()

class Blue(object):
    def toggle(self):
        return Red()

Blue().toggle().toggle().toggle().toggle().toggle() :)

Travis Griggs
"Some of them wanted to sell me snake oil and I'm not necessarily going to dismiss all of these, as I have never found a rusty snake." --Terry Pratchett

More information about the Python-list mailing list