473,787 Members | 2,928 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python Design Patterns

Hello

I am learning Python for in the pass ten months, and have brought a few
books about Python. Most of them are good books by its only right, and all
of them only teach you how to write Python programs using Python syntax and
Python ways, but no one single Python book explicitly teaches you on how to
analyst your application, and structure your programmes in a way, so that,
it is easy to maintain, easily to reuse, (i.e. use loosely couple), and
easily to extend or add new features (programming to Interface instead of
Implementation) without introduce bugs into your existing working codes.

I recently brought a book called "Head First Design Patterns" published by
O'reilly. This book is simply a gem. It shows you how to use and apply
Design Patterns to analyst and structure your code, so that, the programs
can be easy maintains, reuse, modify and extend. (It is the books I have
been looking for a long time while I am learning Python, but cannot find
one). The only caveat about this book is that the authors use Java (not
Python) in the examples.

I wonder, can any Python guru out there translate the Java examples in the
book into Python examples, or write a similar book in Python, perhaps
called "Head First Design Patterns in Python". I think, this will be a
great addition to Python books, and a great benefit to Python community.

P.S. I am not sure is this the right news group to post this request.
Jul 18 '05 #1
4 2868
On 2004-11-29, Tony Ha <to*****@philip s.com> wrote:
I wonder, can any Python guru out there translate the Java examples in the
Should be a good exercise, and not just for gurus ;}.
book into Python examples, or write a similar book in Python, perhaps
I've also wished for a design patterns book aimed at Python, or at least
dynamic languages with first class functions and modules. There's a paper
Python book with "Patterns" in the title, but it has precious little content
in it related to design patterns, at least not the GOF variety.

This web book has the word "Patterns" in it, too:

http://www.brpreiss.com/books/opus7/

But looks like it's mainly data structures.

If you do a google search, and also search the Python Cookbook

http://aspn.activestate.com/ASPN/Python/Cookbook/

you can find examples of:

Singleton
Borg
Null
Factory
Observer (including a Publish/Subscribe recipe)
Memento
State
Decorator
Masquerading and Adaptation patterns (Alex Martelli paper)
Template (another Alex Martelli paper)
Chain of Responsibility
Proxy
Prototype

There must be good examples in actual source code out there, too.
called "Head First Design Patterns in Python". I think, this will be a
great addition to Python books, and a great benefit to Python community.
I just bought this book as well. I must have adult ADD, because I do enjoy
the Head First format, though I disdained it at first.
P.S. I am not sure is this the right news group to post this request.


Yup, this is the place.

Dave Cook
Jul 18 '05 #2
Hello Dave,

Thanks for pointing me to the Cookbook website.

Tony Ha.
"Dave Cook" <da******@nowhe re.net> wrote in message
news:sl******** *************@l ocalhost.locald omain...
On 2004-11-29, Tony Ha <to*****@philip s.com> wrote:
I wonder, can any Python guru out there translate the Java examples in
the
Should be a good exercise, and not just for gurus ;}.
book into Python examples, or write a similar book in Python, perhaps
I've also wished for a design patterns book aimed at Python, or at least
dynamic languages with first class functions and modules. There's a paper
Python book with "Patterns" in the title, but it has precious little

content in it related to design patterns, at least not the GOF variety.

This web book has the word "Patterns" in it, too:

http://www.brpreiss.com/books/opus7/

But looks like it's mainly data structures.

If you do a google search, and also search the Python Cookbook

http://aspn.activestate.com/ASPN/Python/Cookbook/

you can find examples of:

Singleton
Borg
Null
Factory
Observer (including a Publish/Subscribe recipe)
Memento
State
Decorator
Masquerading and Adaptation patterns (Alex Martelli paper)
Template (another Alex Martelli paper)
Chain of Responsibility
Proxy
Prototype

There must be good examples in actual source code out there, too.
called "Head First Design Patterns in Python". I think, this will be a
great addition to Python books, and a great benefit to Python community.
I just bought this book as well. I must have adult ADD, because I do

enjoy the Head First format, though I disdained it at first.
P.S. I am not sure is this the right news group to post this request.


Yup, this is the place.

Dave Cook

Jul 18 '05 #3
"Tony Ha" <to*****@philip s.com> wrote in message news:<n7******* ***********@ns2 .gip.net>...
Hello Dave,

Thanks for pointing me to the Cookbook website.


On 2004-11-29, Tony Ha <to*****@philip s.com> wrote:
I wonder, can any Python guru out there translate the Java examples in


For anyone translating Java to Python, I think this article has good advice:

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

Dave Cook
Jul 18 '05 #4
"Tony Ha" <to*****@philip s.com> wrote in message news:<n7******* ***********@ns2 .gip.net>...
Hello Dave,

Thanks for pointing me to the Cookbook website.


On 2004-11-29, Tony Ha <to*****@philip s.com> wrote:
I wonder, can any Python guru out there translate the Java examples in


For anyone translating Java to Python, I think this article has good advice:

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

Dave Cook
Jul 18 '05 #5

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

Similar topics

699
34241
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
58
4031
by: Svein Ove Aas | last post by:
Is anyone working on a python-to-native compiler? I'd be interested in taking a look. Come to think of it, is anyone working on a sexpr-enabled version of Python, or anything similar? I really miss my macros whenever I try to use it...
36
6405
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but something I'll need in this case is some experience-based set of rules about how to use python in this context. For example... is defining readonly attributes in classes worth the hassle ? Does duck-typing scale well in complex
63
5185
by: Davor | last post by:
Is it possible to write purely procedural code in Python, or the OO constructs in both language and supporting libraries have got so embedded that it's impossible to avoid them? Also, is anyone aware of any scripting language that could be considered as "Python minus OO stuff"? (As you can see I'm completely new to Python and initially believed it's a nice&simple scripting language before seeing all this OO stuff that was added in over...
22
1767
by: lechequier | last post by:
Let's say I define a list of pairs as follows: >>l = Can anyone explain why this does not work? >>h = {}.update(l) and instead I have to go: >>h = {} >>h.update(l) to initialize a dictionary with the given list of pairs?
24
2112
by: John Salerno | last post by:
Since Python does so many things different, especially compared to compiled and statically typed languages, do most of the basic design patterns still apply when writing Python code? If I were to read a design pattern book (such as Head First Design Patterns), could I apply their Java examples to Python easily enough, or does Python require a different perspective when applying patterns?
0
268
by: Cameron Laird | last post by:
QOTW: "This PyCon has been better in so many respects than the three that preceded it. ... PyCon will continue to improve." - Steve Holden, chairman of PyCon 2003-2005 http://holdenweb.blogspot.com/ "Design patterns are kind of like sarcasm: hard to use well, not always appropriate, and disgustingly bad when applied to problems they are not meant to solve." - ajones "Most of most design patterns is to work around the fact that it's
6
1969
by: Gabriel Genellina | last post by:
Hello Most authors talk about Java/C++, and describe patterns used as a workaround to their static class model; the dynamic nature of Python allows for trivial implementations in some cases. I've seen some design patterns examples on the ActiveState site, and some discussions some time ago on this list. But does anyone know of a complete discussion/analysis of patterns in Python? Books, articles, web pages... Unfortunately the...
10
3679
by: vital | last post by:
Hi, I am designing the middle tier of a project. It has 6 classes and microsoft application data access block. The six classes are DBServices, Logger, ProjectServices ... etc. and all these classes talk to front-end directly. Do I need to use any design pattern in this? or what kind of design pattern is this?
0
9655
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
10363
Oralloy
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...
1
10110
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,...
0
8993
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...
1
7517
isladogs
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...
0
5398
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
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
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
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.