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 2 986
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
<mypackage>/__init__.py
<mypackage>/model.py
<mypackage>/view.py
<mypackage>/controller.py
if you *must*.
Diez
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.htm...00000000000000
>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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sean |
last post by:
Hi,
I need to save data into a XML file using an existing schema (I have the
..xsd file)
If the record exists then the data must be read from the DB in MS Access
2000 and saved into a XML file.
If the record does not exist then the apps must create a new record into XML
file (this record must not be saved into the database)
|
by: Bennett Haselton |
last post by:
If I add this to my web.config file:
<authentication mode="Forms">
<forms name=".ASPXUSERDEMO" loginUrl="login.aspx" protection="All"
timeout="60" />
</authentication>
I can configure the application so that users who try to access a page
in the application, get redirected to login.aspx where they have to
sign in. (And the "signing in" is handled in the codebehind page of
|
by: Sean |
last post by:
Hi,
I need to save data into a XML file using an existing schema (I have the
..xsd file)
If the record exists then the data must be read from the DB in MS Access
2000 and saved into a XML file.
If the record does not exist then the apps must create a new record into XML
file (this record must not be saved into the database)
|
by: jehugaleahsa |
last post by:
On Jun 13, 3:09 pm, "Bob Powell " <b...@spamkillerbobpowell.net>
wrote:
I apologize for the size. I should have probably put this on a blog or
something.
I'm not interested in tools. I interested in concepts / better ways of
handling day-to-day design decisions.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |