-2

私はこのスタックトレースを取得しています:

  File "/usr/lib/python2.7/site-packages/gitflow/gitflow/flow_conditions.py", line 3, in <module>
    from gitflow.flow_config import ConfigManager
  File "/usr/lib/python2.7/site-packages/gitflow/gitflow/gitflow/flow_config.py", line 19, in <module>
    from gitflow.flow_workflow import FlowCommand, WorkflowCommand
  File "/usr/lib/python2.7/site-packages/gitflow/gitflow/gitflow/gitflow/flow_workflow.py", line 5, in <module>
    from gitflow.flow_conditions import ConditionFactory
  File "/usr/lib/python2.7/site-packages/gitflow/gitflow/gitflow/gitflow/gitflow/flow_conditions.py", line 3, in <module>
    from gitflow.flow_config import ConfigManager
  File "/usr/lib/python2.7/site-packages/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/flow_config.py", line 19, in <module>
    from gitflow.flow_workflow import FlowCommand, WorkflowCommand
  File "/usr/lib/python2.7/site-packages/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/flow_workflow.py", line 5, in <module>
    from gitflow.flow_conditions import ConditionFactory
  File "/usr/lib/python2.7/site-packages/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/flow_conditions.py", line 3, in <module>
    from gitflow.flow_config import ConfigManager
  File "/usr/lib/python2.7/site-packages/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/flow_config.py", line 19, in <module>
    from gitflow.flow_workflow import FlowCommand, WorkflowCommand
  File "/usr/lib/python2.7/site-packages/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/gitflow/flow_workflow.py", line 5, in <module>
    from gitflow.flow_conditions import ConditionFactory
  File "/usr/lib/python2.7/site-packages/gitflow/flow_conditions.py", line 3, in <module>

私は自分のコードに問題があることを見つけることができず、Python の問題であるとは確信が持てなかったという考えが残ります。循環依存。Pythonは循環依存関係をうまく処理しますか、それとも問題が解決するかどうかを確認するためにそれらをリファクタリングする必要がありますか?

ありがとう。

4

1 に答える 1

4

あなたがこれを持っている場合:

# in foo.py
from bar import cat

# in bar.py
from foo import dog

これにより、両方のモジュールが相互にインポートしようとする無限ループが作成されます。循環依存は悪い設計の印であると一般に理解されているため、Python は特にこの問題を処理しません。

于 2013-10-11T14:57:39.853 に答える