Re: Files application architecture

2008-09-08 Thread Benjamin Watine

Bruno Desthuilliers a écrit :

Benjamin Watine a écrit :

Hi,

I'm about to develop a small python application and I wonder how to 
organize files in this application.

I'm familar to java, so I'm tempted to use the same convention


http://dirtsimple.org/2004/12/python-is-not-java.html


: 1 file per class and 1 folders per package.


Don't. This is a waste of time and a pain to maintain, and more over it 
doesn't make any sense since Python doesn't force you to put everything 
in classes.



I know that packages doesn't exists in python,


Did you actually read the doc ? While Python's packages are not the same 
thing as Java's, they do exist.


http://docs.python.org/tut/node8.html#SECTION00840

they are modules instead. May I create specific module for each "group 
of class" ?


The usual way to get cohesive modules is indeed to group closely related 
objects (classes, functions, etc) in a same module.


My application follow the MVC paradigm, so basically, I've a package 
Model, a package View, and a package Controller.


If your app is small, having _modules_ models, views and controllers 
should be enough.


So, what are best practices for organizing files and folders in a 
small python project ?


The best practice is to keep things simple, as usual.



Thank you all for your good advices and links. I'm new to python and I 
have yet a lot of things to learn !


Now, I would like to take a look to a well coded wxPython application. 
Could anybody indicate a project that I could take as reference for 
standard python coding style ?


Regards,

Ben
--
http://mail.python.org/mailman/listinfo/python-list


Re: Files application architecture

2008-09-05 Thread Bruno Desthuilliers

Benjamin Watine a écrit :

Hi,

I'm about to develop a small python application and I wonder how to 
organize files in this application.

I'm familar to java, so I'm tempted to use the same convention


http://dirtsimple.org/2004/12/python-is-not-java.html

: 1 file 
per class and 1 folders per package.


Don't. This is a waste of time and a pain to maintain, and more over it 
doesn't make any sense since Python doesn't force you to put everything 
in classes.



I know that packages doesn't exists in python,


Did you actually read the doc ? While Python's packages are not the same 
thing as Java's, they do exist.


http://docs.python.org/tut/node8.html#SECTION00840

they are modules instead. 
May I create specific module for each "group of class" ?


The usual way to get cohesive modules is indeed to group closely related 
objects (classes, functions, etc) in a same module.


My application 
follow the MVC paradigm, so basically, I've a package Model, a package 
View, and a package Controller.


If your app is small, having _modules_ models, views and controllers 
should be enough.


So, what are best practices for organizing files and folders in a small 
python project ?


The best practice is to keep things simple, as usual.


--
http://mail.python.org/mailman/listinfo/python-list


Re: Files application architecture

2008-09-05 Thread Gabriel Genellina
En Fri, 05 Sep 2008 12:53:12 -0300, Benjamin Watine <[EMAIL PROTECTED]>  
escribió:


I'm about to develop a small python application and I wonder how to  
organize files in this application.
I'm familar to java, so I'm tempted to use the same convention : 1 file  
per class and 1 folders per package.


You don't *have* to artificially restrict yourself to one class per file.  
In Python it's common to place several related classes in the same module  
(i.e., file). You don't have to write so much boilerplate code as in Java,  
so classes tend to be smaller in size; you may even find classes with an  
empty body.



I know that packages doesn't exists in python, they are modules instead.


Uh? Have you read the Python Tutorial?
http://docs.python.org/tut/node8.html#SECTION00840

So, what are best practices for organizing files and folders in a small  
python project ?
I've found PEP8 (http://www.python.org/dev/peps/pep-0008/) that gives a  
lot of good hints on coding convention, but nothing about files  
organization.


A small application may consist of just a main entry point and some  
imported modules, all residing in the same directory. It might not require  
to define any package. Perhaps later, when some module grows too much, you  
may want to refactor it, creating a package. But try to keep simple things  
simple.


--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: Files application architecture

2008-09-05 Thread Diez B. Roggisch

Benjamin Watine schrieb:

Hi,

I'm about to develop a small python application and I wonder how to 
organize files in this application.
I'm familar to java, so I'm tempted to use the same convention : 1 file 
per class and 1 folders per package.


I know that packages doesn't exists in python, they are modules instead.


This is wrong. There are packages & modules in python.

http://docs.python.org/tut/node8.html

And please *don't* do put one class per module, as you would do in Java! 
Instead, group related classes into modules, breaking them up into 
several submodules if size or differences in usage suggest so.


May I create specific module for each "group of class" ? My application 
follow the MVC paradigm, so basically, I've a package Model, a package 
View, and a package Controller.


So, what are best practices for organizing files and folders in a small 
python project ?
I've found PEP8 (http://www.python.org/dev/peps/pep-0008/) that gives a 
lot of good hints on coding convention, but nothing about files 
organization.


The MVC pattern is more important in terms of actual classes written, 
not so much regarding their distribution over a set of files. If you 
want, start with one big single module inside a application-naming 
package - or even no package at all. Split up if you need to.


Or just go for

/__init__.py
/model.py
/view.py
/controller.py


if you *must*.

Diez
--
http://mail.python.org/mailman/listinfo/python-list


Files application architecture

2008-09-05 Thread Benjamin Watine

Hi,

I'm about to develop a small python application and I wonder how to 
organize files in this application.
I'm familar to java, so I'm tempted to use the same convention : 1 file 
per class and 1 folders per package.


I know that packages doesn't exists in python, they are modules instead. 
May I create specific module for each "group of class" ? My application 
follow the MVC paradigm, so basically, I've a package Model, a package 
View, and a package Controller.


So, what are best practices for organizing files and folders in a small 
python project ?
I've found PEP8 (http://www.python.org/dev/peps/pep-0008/) that gives a 
lot of good hints on coding convention, but nothing about files 
organization.


Thanks in advance !

Ben


--
http://mail.python.org/mailman/listinfo/python-list