File: class/Extras/Other/PriorClasses/schwab-sep12/suits.py

def f1(): ...
def f2(): ...

handlers = {'club':  f1,
            'heart': f2,
            ...}

suit = 'club'

handlers[suit]()

--------------------------------

def club(): ....

suit = 'club'

eval(suit)()

------------------------------

class Handlers():
    def handle(...): ...

class club(Handler):
    def handle(): ...

class heart(Handler):
    def handle()...

eval(suit)().handle()



[Home page] Books Code Blog Python Author Train Find ©M.Lutz