2

Is there a difference between these two import statements in python

1) from .models import Q

2) from models import Q

I am a little bit confused with the dot, because models.py and file.py(where import is executed) are in the same directory.

Any help will be appreciated.

andrey
  • 1,867
  • 3
  • 21
  • 34

1 Answers1

4

The dot tells python that the module is in the current directory. Without the dot, python will look up the module following standard procedures (from the system path, python path, current directory etc.). You can read more about it here: https://docs.python.org/2/tutorial/modules.html, paying attention to the relative path part

neiht
  • 313
  • 2
  • 5