Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I come from a PHP background so I'm used to everything being in one place. I want to install a python program (Zine)so that I can hack on it. The instructions I've found install it to the system in multiple folders. I do not want to edit files that are installed in Linux system directories.

What is the python way to layout the directory on the filesystem for a web program that under active development?

would it be:





share|improve this question
Take a look at virtualenv. If you want/need to experiment with packages that should replace your system packages, you can easily create a sandbox to experiment and/or reproduce your deployment environment. – 9000 Jul 3 '11 at 17:44
What do you use to run Python code? It's typical nowadays to run a Python-based web server that runs your code and hide it behind a 'normal' web server, usually via FastCGI. This way, you don't even need to give the webserver account any access to your code/data, since your Python server runs under a different user. Or do you use mod_python? – 9000 Jul 3 '11 at 17:50
I will be using mod_wsgi. I want to create a self contained python app (including htdocs) so I can keep it versioned in git, which also helps with deployment across my live, test and dev servers. – Supermighty Jul 3 '11 at 19:03

Python uses directories to form packages of modules. You then import the module (or what you need from a module) so it can be used in the file you are currently working in.

If the file's path is sound\effects\, you would import it like this:

import sound.effects.echo
share|improve this answer
So just put everything in my web root and import from there? htdocs/python/package – Supermighty Jul 3 '11 at 13:41
They just need to be somewhere that Python can find it. Module Search Path. – unholysampler Jul 3 '11 at 14:36
Don't put your packages to htdocs/ unless you want everyone to observe your source code (or, worse, configs and data files). Put the code somewhere where your server can access it and put that dir on PYTHONPATH of your Python interpreter. – 9000 Jul 3 '11 at 17:46
Sounds like there is no best practice for file location with web applications. – Supermighty Jul 3 '11 at 18:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.