user5856294
user5856294

Reputation:

Python Package Paths :: Finding Directories that Should Be .py Files

As I work through the Django tutorials, I like to see with my own eyes the module and class/attribute that I am inheriting via import by going to the source code at Github.

However, and I have attached pics to illustrate that I (think) I went to the right place, but the files seem to be missing.

  1. For example, in Django tutorial Part 1:

from django.conf.urls import include, url

So I go to Github django code and I find:

django/django/conf/urls

What I find is that urls is a directory with only files : __init__.py, i18n.py and static.py.

There is no urls.py file which might have url() or include() methods.

Same with models.Models.

  1. from django.db import models

On django Github site I follow the directories...

django/django/db/models  models is a directory, not a file with a class Model()

So, what am I missing here?

Looking forward to a few bread crumbs :)

Upvotes: 2

Views: 50

Answers (1)

9000
9000

Reputation: 40894

If you're looking for the source of module foo.bar, it can be one of the two:

  • foo/bar.py
  • foo/bar/__init__.py

Also note that often upper-level modules re-export selected names imported from deeper-down modules: a name may be merely imported, not otherwise defined; e.g. django.db does a lot of this.

Upvotes: 2

Related Questions