python中的工厂设计模式
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python中的工厂设计模式相关的知识,希望对你有一定的参考价值。
""" params is a string of the class that you want example: my_class = "do_something" instance = factory(my_class) the name module is hard coded ... """ def factory(cls_string, *args): cls = getattr(module, cls_string) return apply(cls, args)
以上是关于python中的工厂设计模式的主要内容,如果未能解决你的问题,请参考以下文章