Hi.
I found a lot of documentation about how to code in Python, but not
much about how you organize your code in various modules / packages ...
As I am not yet used to python, this puzzle me a bit.
So, can anyone explain how one should organize and store its code ? the
uses of __init__.py files ? Maybe my question is not very clear, but I
hope someone will understand anyway ...
Thomas 2 1339
Thomas Girod wrote: Hi.
I found a lot of documentation about how to code in Python, but not much about how you organize your code in various modules / packages ... As I am not yet used to python, this puzzle me a bit.
So, can anyone explain how one should organize and store its code ? the uses of __init__.py files ? Maybe my question is not very clear, but I hope someone will understand anyway ...
Well... As a starting point relative to Python specific stuff (use of
__init__.py etc), the Fine Manual is your friend: http://www.python.org/doc/2.4.2/tut/node8.html
Now for best practices and whatnots, this isn't really specific to
Python. Try to have modules with high cohesion and low coupling, and
it'll be fine. Eventually try to provide a facade class or function for
complex packages (this is a current pattern in the standard lib).
Also, python-is-not-java, so don't feel commited to putting everything
in classes when plain functions would do, and avoid the 1:1 class/file
Java plague !-)
My 2 cents...
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
bruno at modulix wrote: Thomas Girod wrote: I found a lot of documentation about how to code in Python, but not much about how you organize your code in various modules / packages ... As I am not yet used to python, this puzzle me a bit.
Now for best practices and whatnots, this isn't really specific to Python. Try to have modules with high cohesion and low coupling, and it'll be fine. Eventually try to provide a facade class or function for complex packages (this is a current pattern in the standard lib).
Also, be aware of dependencies between packages and make sure they are
acyclic - if a module in package A imports a module in package B, then A
depends on B and B should not be allowed to also depend on A either
directly (module in B imports module in A) or indirectly (module in B
imports module in C which imports module in A).
If you follow this rule your packages will be more testable and
reusable. The alternative tends to devolve into
everything-depends-on-everything-else which makes testing harder and
reuse nearly impossible.
Kent This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Amardeep Verma |
last post by:
Hi,
I would like to determine the Country and Organization from a given
IP. I have to write a JSP, which when given the IP address gives the
country and the organization to which the IP belongs. The organization
may be the ISP, or a MNC or any other corporate/government body, or it
may be of an individual. I have to do it progamitically from...
|
by: Jo Vermeulen |
last post by:
Hello,
I was wondering if Java supports a feature of C# (or .NET in general),
namely compiling code at runtime.
This is nice for scripting purposes. Users can script the application in
real programming languages (such as C#, VB.NET, ...). This is done using
the System.CodeDom.Compiler namespace, if I recall correctly.
...
|
by: Steven T. Hatton |
last post by:
This is a purely *hypothetical* question. That means, it's /pretend/,
CP. ;-)
If you were forced at gunpoint to put all your code in classes, rather than
in namespace scope (obviously classes themselves are an exception to this),
and 'bootstrap' your program by instantiating a single application object
in main(), would that place any...
|
by: John F |
last post by:
Currently I'm working on a C# app for a large organization (700 users
nationwide). This App is still under development. I have setup code in my
App to pull C# source code from a database and dynamically compile it at
runtime. All source code stored in the database will be of Type Form and all
forms will load as children of an MDI. Once I...
|
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte buffer into the character
pointer. The code looks like the following:
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
BOOL APIENTRY...
| |
by: J |
last post by:
I'm early in my C# larval stage, so I'd like a little direction to help
understand good code organization. Take for example a program I have
written in another language that does the following:
On a regular basis, check a 'hot directory' for incoming files. (Maybe every
15 minutes during business hrs.)
For each file
move to an archive...
|
by: tshad |
last post by:
I am just trying to decide whether to split my code and uses code behind. I
did it with one of my pages and found it was quite a bit of trouble.
I know that most people (and books and articles) like it because you can
split the code from the design. That is logical. But if you are the only
one working on the code, it seem a little...
|
by: Michel Sanner |
last post by:
Hello,
One of the greatest feature of Python in my opinion is the way the
interpreter can be used to integrate a wide variety of
software packages by dynamically linking them. This approach has been
extremely successful for us so far but now I run
into a license nightmare.
Some the libraries we wrapped using SWIG are under GPL but the...
|
by: Bart Van der Donck |
last post by:
Hello,
I'm posting the software for one-FAQ-a-day as described on
http://tinyurl.com/qcxw7
(comp.lang.javascript, July 18 2006, titled "CLJ newsgroup FAQ)
and on
http://tinyurl.com/ppt2s
(comp.lang.javascript, July 22 2006, titled "Automation of
comp.lang.javascript FAQ")
|
by: Jeff Gardner |
last post by:
Greetings:
I am attempting to get conditional output based on POSTed form data.
If the posted value is either the key or value of an array, $x=key and
$q=foo. elseif it is neither key nor value(I tried || too) , $q=bar.
Even though $x is properly assigned the new value, $q always ends up
being bar. Abstractions aside, here's the code: ...
|
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...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
| |
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |