Python: Prevent package importing itself
===

I'm not sure I've phrased correctly the question. I have created a large code with a number of sub-packages, and for simplicity let's call it 'CODE'.

The problem is: 'CODE' appears in the namespace so I can have `CODE.CODE` or `CODE.CODE.CODE`, etc... an infinite number of times which looks strange to me and is probably (I guess) a hint that something is wrong (although the code works perfectly without warning).

I guess the problem has something to do with my `__init__.py` and the structure of my code, so I give some more informations here.

Simplified code structure:

    CODE
      | __init__.py
      | tools
         | mytools.py
      | other
         | init.py
      | sub
         | module.py
     
  

File: `__init__.py`

    import CODE.tools.mytools as MyTools
    import CODE.other.init
    
    OBJ = CODE.other.init.function()
    ...

The file `mytools.py` do not import `OBJ` from CODE, or any other module that may import `OBJ`.
`init.py` may import modules such as `mytools.py`.
Finally, modules like `module.py` may import either `mytools.py` or `OBJ` (from CODE). Usually, all import are made with absolute import, such as in: `from CODE.sub.module import func`.

Does anyone have an explanation for such a behavior. I did not find any related question on SO, but it may be due to the wrong phrasing of mine.

