[Tutor] Python module structure & directories

Karim kliateni at gmail.com
Thu Nov 25 10:53:32 CET 2010


Another possibility is to place you python library in the site package 
of your network installation,
namely for my computer:

*$HOME/build/python/src/Python-2.7.1rc1/Lib/site-packages*

I build the latest release of python (rc1). But At build time I believe that
the path to the libraries is hard-coded somewhere. Indeed, I provide
the python v2.7.1rc1 package along with my application and I use PYTHONPATH
to overcome this fact and point to the libraries of v2.7.1rc1 and PATH 
for python exec.

Like that I am independent of the version of python present on a 
particular machine.

Best Regards
Karim

On 11/25/2010 02:23 AM, Alan Gauld wrote:
>
> "Judy Chen" <jgc617 at 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.
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101125/0448f58b/attachment.html>


More information about the Tutor mailing list