我在工厂类静态方法中访问基类属性时遇到问题
class BaseGeometryShape:
"""
Base class for geometry objects
"""
def __init__(self, name):
self.name = name
class ShapeFactory:
@staticmethod
def create_shape(shape: str, params: List[str]):
#todo
def get_info(shape: str, params: List[str]):
shape = ShapeFactory.create_shape(shape, params)
info = shape.name + '\n'
return info
我假设我必须在 ShapeFactory 类中使用 BaseGeometryShape 类,因为 get_info() 函数中有 shape.name 行。希望有人知道这件事。谢谢。