Circular imports

If module A imports module B which imports module A, we have a circular dependency which may result in an error like: AttributeError: 'module' object has no attribute 'xxx'. To understand this problem we have to be aware that import statements are executed at run-time. In the example above module A is imported first. The name space is empty until def and class statements are executed. However, usually module B ise imported at the very beginning of A, before functions and classes have been defined. So, if B refers to a symbol contained in A, it will not find it and an error will be thrown.

These are possible solutions to the problem: