Tagged Questions
2
votes
0answers
36 views
Proof of concept and learning exercise for the 'ports and adapters' architecture
The script creates a simple app with a GUI containing a input field and a button to select a folder. On startup a default value is set to the input field. If the user types a value or selects a ...
3
votes
2answers
78 views
2
votes
1answer
70 views
Improvements in repository pattern [closed]
I am trying to learn the clean architecture by Uncle Bob. I wanted some basics and following this good post I tried to implement it in python with some minor differences.
...
7
votes
1answer
109 views
Observer pattern implementation without subclassing
I have not yet seen an implementation of the observer pattern in Python which satisfies the following criteria:
A thing which is observed should not keep its observers alive if all other references ...
1
vote
1answer
65 views
Implementing command pattern in Python
I did some study on the command pattern but most of its examples were in Java so, there must be some difference in implementation in Python. I implemented it in Python with some minor differences, ...
3
votes
1answer
234 views
Modelview programming in PyQt4
In my first attempt, I have tried to load images from disk and load it to a QTableView using QAbstractTableModel. I'd like a ...
1
vote
1answer
42 views
Checking sensors in an environment
I have the following diagram (did this only to ask here, it's obviously missing details):
From the diagram you can see I have to check if all sensors in an environment are respecting the ...
7
votes
1answer
4k 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 ...
4
votes
1answer
157 views
State Design Pattern in Python
I'm trying to find the best - read: readable, maintainable, robust, threadsafe, usable - solution for a State Machine in python.
For this I've been looking at the State Design Pattern. However I want ...
3
votes
1answer
394 views
Run a TCP server listening for incoming messages
I've written the following code, but I need some review on design style. I want to develop a library/module and expose an API to client programs. How do I do that?
The code just runs a TCP server ...
3
votes
2answers
113 views
Python coding style from Java background
I am pretty new to Python and just wanted to make sure I am going in the right direction with my coding style.
After reading this, I'm not so sure.
The following is a convenience class that has ...
2
votes
3answers
136 views
Does this code violate the Single Responsibility Principle?
This is my solution to Project Euler problem 2:
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
The class ...
1
vote
4answers
197 views
Feedback on logic implementation of PyQt4 based Image gallery using QTableView
I have made an application to display images in the form of gallery, from terminal if you are standing at the same location then it will open those images in the gallery if it does not have it will ...
0
votes
0answers
333 views
Data pipeline processing framework
I'm trying to build a framework similar to Scrapy ItemPipelines or Pipeless. The motivation is to be able to build generic data pipelines via defining a modular collection of "pipe" classes that ...
2
votes
0answers
118 views
1
vote
1answer
83 views
Feedback on logic implementation and testing
This is my forked branch attempting to make the code better, This is an application for having a slide show of photographs in current directory or supplied as argument.
Use keyboard controls[left to ...
1
vote
3answers
78 views
CSV file cleanup
I'm fairly new to Python and am going to be parsing hundreds of thousands of names eventually. What I wanted to do was take individual CSV files, and create new CSV files with only the info I wanted. ...
2
votes
1answer
54 views
Collecting Parameter vs overloading addition
I'm reading TDD By Example by Kent Beck (which I highly recommend, if you haven't read it!) In The xUnit Example, he discusses how to collect the results of multiple tests in a single ...
2
votes
2answers
95 views
Deep iterations with side effects
Suppose I need to process a list of list of list of many objects, where the data usually comes from third party APIs.
For the sake of an example, lets assume we have many users, and for each user we ...
0
votes
2answers
110 views
Extending a simple Python console program with external code. Did I handle this correctly?
I'm a hobbyist Python programmer with not much experience.
I wrote some code for a solution to a Tic Tac Toe AI problem on the internet.
Then yesterday I wrote a simple console Tic Tac Toe game for ...
2
votes
2answers
584 views
Global variables in python, bottle microframework
I'm sort of at a loss for what to do with webapps and whether what I'm doing is actually allowed or not. Here is a sample of the type of thing i'm doing at the moment. I need a list that is accessible ...
1
vote
2answers
64 views
Changing the state of another entity into the constructor method
I have a Clock class who inherites from pyglet.clock.Clock and behaves like a Singleton.
Into the constructor method I have the following line:
...
7
votes
1answer
4k 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 ...
5
votes
2answers
228 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
299 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
87 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 ...
1
vote
1answer
436 views
proxy pattern in Python
This is my try at the proxy pattern.
What do you Pythoneers think of my attempt?
...
2
votes
0answers
283 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 :
...
2
votes
2answers
180 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 ...
2
votes
0answers
118 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
568 views