Hello,

I use to have it under src/lib as follow:

src/lib/python
src/lib/tcl
src/lib/c

All *.py modules are in src/lib/python with all the possible modules hierarchy.

Then, At build time I copy lib root directory in the install. (with all C code compiled).

Then the startup bin executable do the following as Alan said:

*if ! echo $PYTHON | grep "<PREFIX_PATH_TO_LIB>/lib" > /dev/null ; then
  export PYTHONPATH="<PREFIX_PATH_TO_LIB>/lib:${PYTHONPATH}"
fi*

The conditional statement is here just to not overload the environment variable.

Best Regards
Karim

On 11/25/2010 02:23 AM, Alan Gauld wrote:

"Judy Chen" <jgc...@yahoo.com> wrote

I am very new to Python, I worked on C/C++ before.
I would like to know is it a good practice to put Python development code under

../src/UI/foo.py
../src/businesslogic/bar.py, etc.

Thats fine, especially if its a big project.
src means source code and python is a type of source just as C is.

or should we eliminate "src' directory since it is not pythonic, or it very C/C++ like.

Who says its not pythonic?
src is a perfectly common name to use on Unix type systems for all types
of source code.

I was told that the above directory/file structure does not apply to
Python, since Python's source code are objects.

The source code is not really an object but becaiuse you can import
any python file as a module, and modules are objects (once they are
loaded) you might get away with saying that. But really, python source
files are no different to any other source files when it comes to organising
your file system for a project.

Are there any standard for how Python source code to be structured?

Not that I'm aware of. There are some standards for how to create
packages which might restrict things a little but oprovided you have
your PYHONPATH set up tio find the modules all should be well.
And you might want to create a build script that moves the modules
from src to lib in the production file system. But on a project, especially
one  with multiple programming languages, having all source files in
one place is a definite plus IMHO.

Another thing to do would be take a look at some of the Python projects
on Sourceforge - DIA for example. See how they structure their code.


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to