私はそれがグリーンホーンの質問であることを知っています。しかし。クラスを含む非常に単純なモジュールがあり、そのモジュールを呼び出して別のモジュールから実行したいと考えています。そのようです:
#module a, to be imported
import statements
if __name__ == '__main__':
class a1:
def __init__(self, stuff):
do stuff
def run_proc():
do stuff involving 'a1' when called from another module
#Module that I'll run, that imports and uses 'a':
if __name__ == '__main__':
import a
a.run_proc()
ただし、他の人には明らかな理由で、属性エラー: 'Module' object has no attribute 'run_proc' Do I need a static method for this class, or to have my run_proc() method within a class, というエラーが表示されます。インスタンスを初期化しますか?