how to arrange classes in .py files?

Kent kent.yuan at gmail.com
Fri Mar 27 01:51:21 CET 2009


Hi all,

I work with Java. Recently I read some about python, and it is really
impressive. So i decide to learn it in my spare time by a small
application. But i got a question about the python classes. Didn't
find any help with Google.

In java, usually a .java file contains One Class. I read some python
codes, I found one py file can have many classes and functions. Is
there any convention how to manage python classes into .py files?

Now I just deal with my little application exactly in Java style:
package: gui, service, dao, entity, util (from the package name, you
can see the MVC pattern)
gui: wxPython classes
service: business logic, transaction mgmt etc.
dao: Data access classes
entity: "pojo"s
util: some handy utility classes

later VO classes/package may be involved as well.

In above packages, each .py file contains one python class. And
ClassName = Filename

not sure about the right code structure of python oop.

Can anyone give some hint on it? would be great with reason.

Thanks in advance.


regards,

Kent





More information about the Python-list mailing list