Python type hinting without cyclic imports

后端 未结 5 904
太阳男子
太阳男子 2020-11-28 04:57

I\'m trying to split my huge class into two; well, basically into the \"main\" class and a mixin with additional functions, like so:

main.py file:

5条回答
  •  时光说笑
    2020-11-28 05:22

    I think the perfect way should be to import all the classes and dependencies in a file (like __init__.py) and then from __init__ import * in all the other files.

    In this case you are

    1. avoiding multiple references to those files and classes and
    2. also only have to add one line in each of the other files and
    3. the third would be the pycharm knowing about all of the classes that you might use.

提交回复
热议问题