1

If I have 2 very deep python package:

com.acme.some.thing, and com.acme.some.thing2.

Both of them use each other, so thing would import thing2, and thing2 would import thing.

However, in Python this will yield 'cannot import Name X' error due to cyclic import. The only way to let them use each other is to import specific function names, which takes a lot of space, if both modules have identical function names, this is again not possible.

I would always assume that import is just a shorthand for disambiguated names, and has no impact on interpretation. So cyclic import should have no impact at all. Why is it not allowed in Python?

tribbloid
  • 4,026
  • 14
  • 64
  • 103
  • check out: http://stackoverflow.com/questions/744373/circular-or-cyclic-imports-in-python – dima Oct 02 '16 at 16:36
  • If I'd hazard a guess, it would be that it implicates bad design. But that's pretty much opinionated. However, the Python community (and language) are very much in line with thinking like that. But again, it's just a guess. – Gerard van Helden Oct 02 '16 at 16:37
  • Thanks a lot, both answers are very useful. Mind if we make any of them official? – tribbloid Oct 07 '16 at 01:22

0 Answers0