在使用python实现时,有4种方式。大同小异。
catalog使用场景:
类初始化时,入参不同,那么后面执行相同的函数,执行体不同,输出不同。
其中一种写法:
class Catalog(object): """catalog of multiple static methods that are executed depending on an init parameter """ def __init__(self, param): # dictionary that will be used to determine which static method is