473,668 Members | 2,536 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is the name of this Python programming style

I'd like to learn more about this style of programming in Python.

In this style or pattern, a high level class is given an instance
(or a class from which it creates an instance), then uses that
instance to perform its tasks. A user of the higher-level class
can customize the function of that class by implementing or
customizing details in lower-level class.

I've seen it a number of times. It seems quite useful. It
provides loose coupling between a higher-level policy class and a
lower-level mechanism or implementation class. The coupling is
defined by an abstract base class which the lower level class must
implement. This loose coupling frees the higher-level policy
class from dependency on details in a lower-level mechanism class.

One example of this style is in BaseHTTPServer in the Python
standard library. The constructor to BaseHTTPServer takes a
handler class as an argument. The handler class should be
sub-class of BaseHTTPRequest Handler. So, in this example:

- BaseHTTPServer is the higher-level policy class.

- BaseHTTPRequest Handler defines the interface. Or should it be
called the protocol?

- And, the sub-class of BaseHTTPRequest Handler that I'm supposed
to implement is the lower-level mechanism class.

I think the general name for this is Inversion of Control (IoC).

Can someone tell me if this Python pattern or style has a name
among Pythonistas?

It's not unique to Python, of course, but once again Python seems
very well suited to this pattern or style.

I've been reading about PEAK (http://peak.telecommunity.com/).
PEAK supports this style of programming in a much more complex
way. Does anyone have some experience with PEAK? Is the PEAK way
better or more powerful? Learning the PEAK way seems to require
immersion in a complete Zen of PEAK. It is pretty opaque to me.
I'd be thankful for a pointer or URL to help me gain a little
understanding. I've read the tutorial and quite a bit of the PEAK
Wiki. Is there more somewhere?

Thanks for help.

Dave

--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
Jul 18 '05 #1
1 1511
Dave Kuhlman wrote:
In this style or pattern, a high level class is given an instance
(or a class from which it creates an instance), then uses that
instance to perform its tasks.


Delegation.
--
CARL BANKS http://www.aerojockey.com/software
"If you believe in yourself, drink your school, stay on drugs, and
don't do milk, you can get work."
-- Parody of Mr. T from a Robert Smigel Cartoon
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
19001
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
54
6545
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO FRICKIN' COOL!!! ***MAN*** that would save me a buttload of work and make my life sooooo much easier!" As opposed to minor differences of this feature here, that feature there. Variations on style are of no interest to me. I'm coming at this from a...
21
1596
by: godwin | last post by:
Hi all, I wanna thank Martin for helping out with my ignorance concerning execution of stored procedure with python. Now i have decided to write a web app that googles into my companies proprietary database. I need to know whether zope is good for that job. But even the introduction to zope in the zope book was intimidating. Are there any simple options? If so plz tell me how i can obtain it and study it. I should say that i am new to web...
31
2521
by: N.Davis | last post by:
I am very new to Python, but have done plenty of development in C++ and Java. One thing I find weird about python is the idea of a module. Why is this needed when there are already the ideas of class, file, and package? To my mind, although one CAN put many classes in a file, it is better to put one class per file, for readability and maintainability. One can then create packages and libraries, using groups of files, one
10
2841
by: Johnny Lee | last post by:
Hi, I'm new in python and I was wondering what's the difference between the two code section below: (I) class TestResult: _pass_ = "pass" _fail_ = "fail" _exception_ = "exception"
99
4634
by: Shi Mu | last post by:
Got confused by the following code: >>> a >>> b >>> c {1: , ], 2: ]} >>> c.append(b.sort()) >>> c {1: , ], 2: , None]}
8
1999
by: clintonG | last post by:
Every single time neophytes or converts ask about naming and style conventions what are they told by the majority consensus? The answer is "do what you prefer but do so consistently" right? Yes, that's right, that's exactly what is said. People joining a team of developers are also encouraged to cooperate with their peers and adopt what has already been established right? Yes, that's exactly what is encouraged. Teamwork and cooperation...
34
3597
by: emrahayanoglu | last post by:
Hello Everyone, Now, I'm working on a new web framework. I tried many test on the other programming languages. Then i decided to use python on my web framework project. Now i want to listen all of you. What do you want in that web framework(Easy use of Database, Easy use of XML, GUI Designer, etc...)? I'm wating your answers. Thank you for all answers...!
92
3931
by: ureuffyrtu955 | last post by:
Python is a good programming language, but "Python" is not a good name. First, python also means snake, Monty Python. If we search "python" in google, emule, many results are not programming resource. If we search PHP, all results are programming resource. Second, python also means snake, snake is not a good thing in western culture. Many people dislike any things relevant to snake. We must have high regard for the custom.
0
8462
marktang
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...
0
8381
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8799
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7401
agi2029
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...
0
5681
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4205
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...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1786
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.