4
votes
2answers
118 views

Strategy Design Pattern in Python

I'm reading the awesome Head First Design Patterns book. As an exercise I converted first example (or rather a subset of it) to Python. The code I got is rather too simple, i.e. there is no abstract ...
3
votes
1answer
88 views

Python/Django Script - Is it crap? Objects duplicated or passed?

I've written a script using the Django ORM to store 'configuration settings' and interacting with the Google Drive API and another API. The script creates a base project folder and subfolders in ...
0
votes
1answer
48 views

Instance of one class to contain arbitrary number of instances of another class in Python

I'm trying to see if there is a better way to design this. I have a class Animal that is inherited by Male and Female classes (Female class has an additional attribute). I also have a class called ...
3
votes
1answer
182 views

The Observer design pattern in Python in a more pythonic way (plus unit testing best practices)

I'm continuing to work on the Head First Design Patterns book in an effort to become a more efficient and better Python programmer. Code review for the Strategy pattern in Chapter 1 is here with ...
1
vote
1answer
71 views

proxy pattern in Python

This is my try at the proxy pattern. What do you Pythoneers think of my attempt? class Image: def __init__( self, filename ): self._filename = filename def load_image_from_disk( self ...
2
votes
1answer
246 views

The Strategy design pattern for Python in a more pythonic way

I've recently picked up the Head First Design Patterns book in an effort to become a more efficient and better Python programmer. Unfortunately, the code examples in this book are in Java. I'm not the ...
2
votes
0answers
141 views

how to design a good Python class

I am using python moudle urllib3. It occurs to me that is there better way to design a good class when I rebuild my last site crawler. Then, below code comes up : class Global: host = ...
2
votes
2answers
111 views

Performing a chain of mutually dependent actions, and reversing in case of failure

Description I'm writing a program that makes changes to a few Python source files--creating some, and appending content to others. Since some changes depend on others, I check frequently to make sure ...
1
vote
0answers
96 views

Guidance on SoC and passing data between GUI instances (MVC pattern)

I'm fairly new to Python and currently building a small application to record loans of access cards to people in a company. I'm using wxPython for the GUI and SQLAlchemy for the CRUD. I'm loosely ...
3
votes
2answers
418 views

python object pool with metaclasses

class Pool(type): pool = dict() def __new__(clas, *a, **k): def __del__(self): Pool.pool[self.__class__] = Pool.pool.get(self.__class__, []) + [self] ...