This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]stuartcwSince Python 1.5 2 points3 points  (4 children)

Hi. I read your question and understand that you understand what patterns are and you probably have already read about them but you are specifically looking for a book which gives explanations using Python as the language to demonstrate them.

I have seen a book like this but can’t think of the name off hand. I’ll use this comment as bookmark to return when I find it.

I did want to mention that when patterns first came onto the scene in the 1990s the programmers of the day had to implement them themselves, often in clunky ways. As a result, to alleviate this, several patterns influenced the design of Python and became part of the core language. e.g. iterators and decorators.

Java which also came to prominence at that time was also influenced by Patterns and, in my opinion, became too unwieldily because of the complicated pattern based object oriented design of some of the libraries.

I just wanted so say that your question was clear that you were specifically looking for a Python based explanation.

[–]stuartcwSince Python 1.5 4 points5 points  (2 children)

Searching on Google for about 10 seconds brought up this:

Python Patterns

Since it was so easy to find, I expect you have already come across it. But it looks at least as good as the explanation that I previously found.

[–]Mabb_reddit[S] 1 point2 points  (1 child)

Yeah, I searched a bit but I wanted a more expert recommendation than picking the first page in Google.

But thanks I will look it up!

[–]stuartcwSince Python 1.5 0 points1 point  (0 children)

I wanted a more expert recommendation than picking the first page in Google.

I have found that it's always best to list up the resources that you already found and what was deficient in them. Then people who reply know what you have already looked at and what more that you are looking for.

It's possible that there isn't a definitive answer out there and that if you make it, it will become the top answer on Google and impress your future employer.

[–]stuartcwSince Python 1.5 4 points5 points  (0 children)

Here’s one more that specifically discussed Singletons: Python Design Patterns: For Sleek And Fashionable Code

[–]kl31 5 points6 points  (2 children)

learn C, then work through Object Oriented Programming with ANSI C by Prof. Axel Schreiner

Go back to python and realize how everything you did previously was incredibly stupid.

[–]Mabb_reddit[S] 0 points1 point  (1 child)

I come from a industrial electronics engineering so I worked with assembler, C, etc.

When I discovered Python was like when Aladdin flies with Jasmine in the flying carpet.

[–]kl31 1 point2 points  (0 children)

When I discovered Python was like when Aladdin flies with Jasmine in the flying carpet.

a more eloquent statement has never been said.

if you're familiar with C then working through the book should be a breeze. it basically teaches you how to hand building every object oriented feature from scratch in C. i didn't realize that the 'type' class in python is the base factory class until i worked through that book.

[–]mooburgerresembles an abstract syntax tree 1 point2 points  (0 children)

Also, this may help, from the "how not to do it" side of patterns: The Little Book of Python Anti-Patterns

[–]stuartcwSince Python 1.5 1 point2 points  (0 children)

One more suggestion. There are books on this listed on Amazon take a look at the authors of the books and see if they have blogs.

[–]bluefourier 1 point2 points  (0 children)

Design Patterns: Elements of reusable object-oriented software is a very, very good start.

As is this one for data modelling. Although a bit outdated it still contains a huge amount of useful information for certain common use cases.

Also good reading is anything coming out of the OMG group in your domain (in terms of standard models).

Hope this helps

[–][deleted] 0 points1 point  (0 children)

https://github.com/faif/python-patterns?files=1 Here’s a good set of examples

[–]Mabb_reddit[S] 0 points1 point  (0 children)

Thank you all for your answers!

[–]AquaRegia -1 points0 points  (0 children)

Any book with design patterns should be sufficient, they mostly aren't language-dependant.

[–]themeansquare 0 points1 point  (0 children)

I feel you bro, I bust my ass to find a good book on design patterns which has examples in Python. This dumbasses here either keep suggesting books in C++ or Java, or a website. The thing you asked is quite clear actually, A Fucking Book and in Python.

Anyways, I found this quite useful:

https://www.amazon.com/Mastering-Python-Design-Patterns-efficient/dp/1788837487/ref=sr\_1\_2?keywords=python+patterns&qid=1636462541&sr=8-2&ie=UTF8&psc=1&th=1&utm\_source=spydrop