Krab
Krab

Reputation: 6756

Python - loading module from directory

Why python load my module from directory, even if the directory shouldn't be treated as a package (doesn't contains __init__.py)?

app
  main.py
  fake_module
    module.py

this works, even if fake_module doesn't contains __init__.py

import fake_module.module

If i would create regular fake_module with __init__.py and module.py file somewhere in sys.path, will be module.py loaded from this regular fake_module package?

I am using pycharm and python3.3

Upvotes: 1

Views: 221

Answers (1)

Aya
Aya

Reputation: 41950

It looks like the __init__.py is optional as of Python 3.3. See also PEP420.

Upvotes: 7

Related Questions