I am a newbie just getting started with Python. I have trouble understanding the statement "The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path"
Let's say i have a directory structure as shown below:
rootDir (let's say this is in sys.path )
-> filex.py
rootDir
-> _init_.py
-> temp
-> _init_.py
-> filex.py
Without having __init__.py, i cannot access rootDir/temp/filex.py unless i have rootDir/temp in the sys.path. With __init__.py defined as shown above, however, i can access it as a package. Having said this i don't understand the statement "this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path". Can someone please clarify with a use case? Where is the question of hiding the module come into the picture.
Thanks