我有一個有點難以解釋的問題。我有一個由多個類的模塊:someModule.py使用反射窺視模塊及其類
#imports over here
class Default(Base):
def __init__(self):
a = Rectangle() #all these guys derive from Shape
b = Circle()
c = Sphere()
class Foo:
#members over here
#other classes/functions/whatever we can define here, except the boiler plate code to check __main__
我想要做的就是創建從一個特定的基類(如基地)在運行時導出類的一個對象,操作從另一個特定基類(例如Shape)派生的數據成員。含義我想寫一個這樣的腳本,它需要模塊名稱並執行上述任務。任何想法如何我可以做這個使用檢查或別的東西?我已經看過檢查,但沒有找到完成工作的方法。我可能會錯過一些東西。