2

I have two questions:

  1. I'm trying to implement an Observer design pattern in Python. What is the easiest implementation for that?

    I need it to observe the status of machines in a render farm that I'm currently building.

  2. Are there any good Python design pattern books out there?

Community
  • 1
  • 1
Moayyad Yaghi
  • 3,622
  • 13
  • 51
  • 67
  • 2
    Your question says "Observer" the title says "State". Please pick one design pattern for both question and title. – S.Lott Dec 30 '09 at 11:27
  • Duplicate: http://stackoverflow.com/questions/1904351/python-observer-pattern-examples-tips – S.Lott Dec 30 '09 at 11:28

3 Answers3

6

There are already some nice sources of information about design patterns in Python.

Here's an interesting book on Python design patterns.

Last but not least...Alex Martelli gave a very interesting talk regarding this issue for Google Developer Day US.

Edit: After reading that this is a duplicate of another StackOverflow question, I would recommend that everyone read that one as well. There are a lot of useful links and comments there.

Community
  • 1
  • 1
bastianneu
  • 2,059
  • 2
  • 18
  • 31
2

You can find a discussion on python design patterns in this previous question.

An implementation of an observer pattern is given here.

Community
  • 1
  • 1
Frank
  • 10,461
  • 2
  • 31
  • 46
0

Examples of Python implementations of the observer design pattern can be found in the following books:

  • Data formatter: "Every time the value of the default formatter is updated, the registered formatters are notified and take action." [Mastering Python Design Patterns, section "The Observer Pattern" subsection "Implementation" / Kindle pos. 2416]
  • "(... ) Every observer gets a Unit timestamp an will print it out in either the USA (12 hour) format or the (24 hour) EU format." [Learning Python Design Patterns, section "Observer design pattern" subsection "Implementation in Python" /Kindle pos. 900]

Kasampalis, Sakis | Mastering Python Design Patterns | Packt Publishing Ltd. | 1st | 2015

Zlobin, Gennadiy | Learning Python Design Patterns | Packt Publishing Ltd. | 1st | 2013

By the way: A lot of other references to design pattern implementation examples in Python can be found on eswp3.org.

thinwybk
  • 4,193
  • 2
  • 40
  • 76