I suspect that the way I organize C code for a project is different from
the accepted way to organize Python project code. My inclination is to put
all the wxPython UI code in one subdirectory and the number crunching code in
a different subdirectory.
聽聽聽Are there any "standards" for Python code organization? The main advantage
of standards is that there are so many from which to choose.
Thanks,
Rich
路路路
--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
There is no standard, I tend to keep all the code in one file then when it
becomes unmanageable split it in several files.
My suggestion is to do the same BUT if the app you're codding is gonna
be BIG it might be wise to implement it using MVP or MVC as architecture
and split the components right from the start, this will keep you focused
on what you are doing.
Example, in one project I work on the code is split like this:
- model.py (crunching code, database access, data alteration methods)
- presenter.py (this could very well be your ApplicationName.py file,
here all the rest is put together)
- view.py (all the code handling the population of the widgets with data,
basically just a bunch of huge UpdateView methods)
- interactor.py (all the event code, this binds the gui events to
handlers and in handlers after a simple gathering of data everything is
sent to the presenter)
- gui.py (bulk of the wxPython code, widgets creation, layout etc)
- interface.py (some code spited out by wxGlade, all of the classes are
imported in gui.py)
- utils.py some snippets that I keep reusing from project to project,
mostly related to the model.py
- gizmos.py (some custom made wxPython widgets, imported by gui.py)
the beautiful thing is that if code grows, model.py could become model
directory, view could also go in a directory... well you get the picture
FWIW code organisation (filewise) is not really all that important, what
counts is to use the right patterns, to name your variables wisely and to
properly document your code. Python is very friendly toward refactoring
Peter.
路路路
On Fri, 16 Dec 2005 18:19:33 +0200, Rich Shepard <rshepard@appl-ecosys.com> wrote:
Are there any "standards" for Python code organization? The main advantage
of standards is that there are so many from which to choose.
There is no standard, I tend to keep all the code in one file then when it
becomes unmanageable split it in several files.
Peter,
I like to organize the code rather than have everything in a single file. I
now have separate files for each notebook page as well as the main file.
My suggestion is to do the same BUT if the app you're codding is gonna
be BIG it might be wise to implement it using MVP or MVC as architecture
and split the components right from the start, this will keep you focused
on what you are doing.
FWIW code organisation (filewise) is not really all that important, what
counts is to use the right patterns, to name your variables wisely and to
properly document your code. Python is very friendly toward refactoring
I like your idea of keeping all methods in a separate file; I'll probably
keep UI-associated methods with that code, and other methods in a separate
file by category. We also need to call the compiled C libraries (all shared
.so files) so it's going to get complex quite soon. Good thing subversion is
so helpful.
Thanks,
Rich
路路路
On Fri, 16 Dec 2005, Peter Damoc wrote:
--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863