python3 vs python2 import strange behavior

Viewed 39

i have a folder like this

root/
 dmx/
   __init__.py
   dmlib/
     __init__.py
     a.py

 dm/  <-- symlink to dmx/dmlib   

in python2,

import dm #ok
print dm.__file__ #it printed out the path to dm/__init__.py
print dm # <module 'dm' from '......./dm/__init__.pyc'>

import dm.a #ok

in python3

import dm #ok
print(dm.__file__) #it print None
print(dm) # <module 'dm' (namespace)>
import dm.a #ModulenNotFoundError: No module named 'dm.a'

Can someone help me understand why?

====================

UPDATED:

My bad. I finally found that it was clashing with some dm module from some other paths.

print dm.__path__ # this indeed prints out the path to some other place 

Thank you everyone for the help. Really appreciate all the help :)

0 Answers
Related