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:
/web/htdocs/python/modules/app.py
or
/web/python/modules/app.py
/web/htdocs/
or
/web/python/modules/app.py
/web/python/htdocs/
1 Answer 1
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\echo.py
, you would import it like this:
import sound.effects.echo
-
So just put everything in my web root and import from there? htdocs/python/packageSupermighty– Supermighty2011年07月03日 13:41:48 +00:00Commented Jul 3, 2011 at 13:41
-
1They just need to be somewhere that Python can find it. Module Search Path.unholysampler– unholysampler2011年07月03日 14:36:07 +00:00Commented Jul 3, 2011 at 14:36
-
1Don'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– 90002011年07月03日 17:46:44 +00:00Commented Jul 3, 2011 at 17:46 -
Sounds like there is no best practice for file location with web applications.Supermighty– Supermighty2011年07月03日 18:54:56 +00:00Commented Jul 3, 2011 at 18:54
mod_python
?