0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

モジュールの中のモジュール

Posted at

イメージは下記となります。
sample_module2.pyはsample_module1.pyのモジュールをインポートしており。
sample_module3.pyはsample_module2.pyのモジュールをインポートしており、
main.pyはsample_module3.pyモジュールのSampleClass3クラスをインポートしている。
最終的にsam;leClass2の空のインスタンスが変数に格納される

sample_module1.py
class SampleClass1:
    pass
sample_module2.py
from sample_module1 import SampleClass1

class SampleClass2:
    pass
sample_module3.py
from sample_module2 import SampleClass2

class SampleClass3:
    def __init__(self):
        self.sample_class2 = SampleClass2()
main.py
from sample_module3 import SampleClass3

sample_class3 = SampleClass3()
sample_class2 = sample_class3.sample_class2
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?