Python "from [dot]package import ..." syntax

Looking through a Django tutorial I saw the following syntax:

    from .models import Recipe, Ingredient, Instruction

Can someone explain how the .models works / what it does exactly? Usually I have:

    from myapp.models import

How does it work without the myapp part in front of .models?

Possible duplicate: What does a . in an import statement in Python mean?

The . is a shortcut that tells it search in current package before rest of the PYTHONPATH. So, if a same-named module Recipe exists somewhere else in your PYTHONPATH, it won't be loaded.


Back to homepage or read more recommendations: