Why do some Python packages have repetitive directory names?
Question: The question of what the directory structure of a Python project has been
asked a number of times on Stack Overflow (e.g.
[here](http://stackoverflow.com/questions/193161/what-is-the-best-project-
structure-for-a-python-application),
[here](http://stackoverflow.com/questions/35879872/what-is-a-very-simple-way-
to-structure-a-python-project) and
[here](http://stackoverflow.com/questions/35738408/how-do-i-structure-my-
python-project-to-allow-named-modules-to-be-imported-from))

And many answers are given. But one thing that doesn't seem to be clear in any
of those answers is why some projects have repetitive directories. For
example, in [this article](http://as.ynchrono.us/2007/12/filesystem-structure-
of-python-project_21.html) which is often cited, the suggested layout is:

    
    
    <root>/
    |-- Twisted/    
    |   |-- __init__.py
    |   |-- README
    |   |-- setup.py
    |   |-- twisted/ 
    |   |   |-- __init__.py
    |   |   |-- main.py
    |   |   |-- test/   
    |   |   |   |-- __init__.py
    |   |   |   |-- test_main.py
    |   |   |   |-- test_other.py
    |   |   |-- bin/
    |   |   |   |-- myprogram
    

In this example, `/Twisted/twisted/main.py` is the main file

But then on the other hand you have advice [like this](http://docs.python-
guide.org/en/latest/writing/structure/):

> Many developers are structuring their repositories poorly due to the new
> bundled application templates.
    
    
    <root>/
    |-- samplesite/
    |   |-- manage.py  
    |   |-- samplesite/
    |   |   |-- settings.py
    |   |   |-- wsgi.py   
    |   |   |-- sampleapp/
    |   |   |-- models.py
    

> Dont do this.
>
> Repetitive paths are confusing for both your tools and your developers.
> Unnecessary nesting doesnt help anybody. Let's do it properly:
    
    
    <root>/
    |-- manage.py  
    |-- samplesite/
    |   |-- settings.py
    |   |-- wsgi.py   
    |   |-- sampleapp/
    |   |-- models.py
    

My question is not necessarily "which way is better?", since there may be pros
or cons to each way.

Instead, my question is, if I go with the more simplified second style, what
will I lose? Is there a good reason to have a
`/<root>/Twisted/twisted/main.py` directory structure rather than just
`/<root>/twisted/main.py` ? Does it make it easier somehow to share my
application or make the `import` process smoother? Something else?


Answer: I believe the most common layout of python projects is something like this:

    
    
    project/
    |-- setup.py
    |-- bin/
    |-- docs/ ...
    |-- examples/ ...
    |-- package/
        |-- __init__.py
        |-- module1.py
        |-- module2.py
        |-- subpackage/ ...
        |-- tests/ ...
    

Where the project is the name of the project and the package is the name of
the top level import, for example scikits-learn and sklearn. The package has
everything that python should be able to import, and you import using the
package name. For example `from package import thing` or `from package.module1
import thing`. The project has the package and any supporting things like
docs, examples and installation scripts. Notice that there is typically no
`__init__.py` in project because project is not python importable. It is
common for the project and package to have the same name, but not required.

