How do I organize my Python application code?
straton at lampsacos.demon.co.uk
Thu Aug 14 11:00:01 CEST 2008
Fredrik Lundh wrote:
> Dudeja, Rajat wrote:
>> And my problem is that I don't have an understanding of how the code in
>> Python is generally organized, in case my code spans multiple files,
>> modules, etc. I've been using C/C++ althrough my life on Linux and
>> Visaul Studio, so the way their code is organized in a group of header
>> files, source files, etc, I'm looking for a similar way in Python way or
>> an approach to organize my python GUI application code?
> A Python program consists of a script file (the py file you run to start
> the program), and usually one or more additional module files (py files
> that you import). The latter can be organized in packages, where
> appropriate. There's also a search path (sys.path) that you can modify
> in various ways (including from within the program) if you want to fetch
> modules from different locations.
> That's all there is; there's no header files or declaration files or
> explicitly maintained object files etc; the program itself is just a
> bunch of Python files.
> To learn more about this, the "modules" section in the tutorial is a
> good start:
> Looking at the structure of a few existing projects might also be helpful.
I would simply add that if your python script produces one or
more output files (for example a text or graphic file) you
might want to have an 'output' directory in your project.
Some people use a 'src' directory, but that is not nearly as
neccessary as in a complied language.
In Eclipse, if you do produce output files, make them
More information about the Python-list