Why can't module access attributes declared in __init__.py of its package?

Viewed 2372

I have a package structure as follows:

mypackage
  __init__.py
  mymodule.py

I put some "constant" declarations in __init__.py for example:

DELIMITER='\x01'

However, the code in the mymodule.py can't access DELIMITER unless I add:

from __init__ import *

To the top of the mymodule.py file. I suppose I missed a concept here. Is it that whatever is declared in __init__.py doesn't get read into memory until it is accessed via an import statement? Also, is this a typical type of thing to put into the __init__.py file?

2 Answers
Related