我创建了这个类
class Things:
def __init__(self, a, b):
self.a = a
self.b = b
def plot(self,name):
px.scatter(getattr(self, name)).show()
在本例中,可以将属性a
或b
绘制为
thing = Things([1,2,3,4], [2,2,2,2])
thing.plot('b')
但我希望能够使用以下语法绘制属性:
thing.b.plot()
或
thing.a.plot()
你知道这是否可能吗?