Python is a dynamically typed, high-level interpreted programming language. Its design focuses on clear syntax, an intuitive approach to object-oriented programming, and making the right way to do things obvious. Python supports modules and exceptions, and has an extensive standard module library. ...
-2
votes
0answers
26 views
Developing a PyQT application for internal use only [on hold]
I have developed an extremely simple application for my authority using unmodified PyQT libraries.
The program will not be released outside of the organisation and we will not be making any money ...
-4
votes
1answer
30 views
distinct integer partition python [on hold]
I am trying to develop a distinct integer partitioning code in python. This means when partitioning a number, for example 5, the code should return 3 because you can have 3,2 and 4,1 and 5. I found a ...
-2
votes
0answers
15 views
Python package entry_points conflicts with sytem binaries [on hold]
Recently, I decided to develop and share a Python package exposing several entry points.
These entry points have the same name as system binaries like ping or curl. Technically, I wanted to create ...
0
votes
0answers
17 views
How to structure a python project with multiple custom packages
I am trying to structure a Python project in what I would consider a normal way, something like:
project root/
app/
foo/
__init__.py
foo.py
otherFoo.py
...
-5
votes
1answer
35 views
Why we need compile PyQt before use it on Mac?
Why we need compile PyQt rather than simply using 'pip install' to put PyQt to my package repository? What happened during the compiling? Can I compiled PyQt once but allow many Macs through share ...
0
votes
1answer
78 views
'from module import x, y, z' vs 'from module import *'
I always use implicit imports like from module import z, y, z but now I got a project, where all imports are done like from module import * and I'm trying to understand, if there any advantages of ...
-1
votes
2answers
54 views
Is it good practice to store instances within a class variable in Python?
I've come across two Stack Overflow posts that seem to offer conflicting answers:
http://stackoverflow.com/questions/4831307/is-it-bad-to-store-all-instances-of-a-class-in-a-class-field
http://...
-2
votes
0answers
27 views
Something like Node Streams for Python [closed]
Is it something like Node streams for Python? Can Python generators be compared to Node streams?
3
votes
1answer
50 views
Scheduling rule violation design
In the context of sports scheduling, a scheduling rule violation (let's call it simply violation from now on) is produced when trying to allocate a match in an illegal timeslot. There is a wide ...
5
votes
2answers
231 views
self vs super() “inconsistency” in Python
According to Python documentation, super() can be used without arguments inside class definitions, because the compiler implicitly feeds it with contextual arguments:
class C(B):
def method(self, ...
3
votes
0answers
33 views
Data Transfer Between Loosely Coupled Modules of an Application
Let's say we have a rather large project written in Python using the Django framework that is made up of multiple modules (proper term in Django is a project made up of multiple apps, but for the sake ...
-1
votes
1answer
35 views
How to deal with different model types [duplicate]
Background: I need to render the same information in two text formats. To do this, I have a set of model classes that store the appropriate information. I then need to render that same information ...
5
votes
2answers
94 views
How to properly handle global parameters for unit testing in python?
We are implementing many algorithms which typically have lots of shared, publicly known and security-relevant parameters.
Currently, we simply use a class holding all the parameters and two ...
3
votes
2answers
156 views
How to refactor functions?
Let's say I want to have a function to load a project's data from both a json and a file path, the first idea which comes to my mind would be having a couple of functions such as:
def ...
3
votes
1answer
71 views
Simple parallel multithreading script
I'm trying to write a python script that creates 10 threads at a time and runs until I stop it (ie closing the console). I just need it to do basic logging, so when it fails, its just logs a failed ...
4
votes
1answer
107 views
Scheduling: balanced home/away round-robin tournament algorithm
I am trying to achieve a round-robin algorithm for sports scheduling that also guarantees a fair or balanced home/away rotation.
I based my algorithm on the round-robin scheduling algorithm:
def ...
4
votes
1answer
51 views
Advice needed on approach to log raw request/response body from APIs
I need some advice on an approach to log raw request/response data from a few webapps, for all operations and hits on all APIS accessed via HTTP methods (mostly HTTP POSTs), that I have hosted.
...
1
vote
1answer
163 views
Can't properly unit test most parts of a project, serious code smell?
The CMS we're developing is getting really messy. One of the failing parts is "unit testing".
To put it simple: what we call unit testing actually is something rather vague, closer to integration and ...
2
votes
6answers
116 views
Best code-style of reading data in a loop [closed]
Which solution for my small problem would you consider a better style? Is there another better option that I am missing?
The logic is simple: Process data from a source until you get the END token.
...
0
votes
0answers
46 views
Implementing ECB Pattern in MVC Pattern Framework
I am wondering how to implement a fully functional and legitimate ECB (Entity Control Boundary) pattern of design using a typical framework (Rails, Django, etc) that is centered around the MVC pattern....
-1
votes
0answers
68 views
Get data from scrap server [duplicate]
I deploying a web scrap server using scrapy. The scenario is a Linux server running mongoDB (or maybe mySQL I'm not sure at all...) and python scripts with scrapy framework.
The main question is what ...
1
vote
1answer
32 views
Get data from scrap server
I deploying a web scrap server using scrapy. The scenario is a Linux server running mongoDB (or maybe mySQL I'm not sure at all...) and python scripts with scrapy framework.
The main question is what ...
4
votes
3answers
185 views
Local client-server communication through files or TCP?
I have a Python client launching a subprocess in C++.
The C++ program runs several threads that need to report results to the Python client.
Knowing that both the Python client and the C++ ...
1
vote
0answers
64 views
How to pass complex ORM objects to background workers?
I've been wondering something about how we pass complex ORM objects to background workers — in my case, Django models and Celery, but this could apply to any similar background processing framework.
...
0
votes
5answers
121 views
Is it better to have many specified exceptions or some general that are raised with specified description?
What is the better way to organize exception in a Python project? What is the right way to use exception description?
For example I have a function that parse email and return some data from it's ...
1
vote
1answer
46 views
Should callbacks be called with named or positional arguments?
The question is asked in the context of Python, but it is also relevant for any languages with named parameters support.
If some entity in my code (e.g. a pubsub implementation) or even a simple ...
3
votes
2answers
122 views
three overlapping project - how to organize
At the moment I am developing three scientific software projects (computer vision) in parallel in Python and scratching my head about organization, clean code and easy extensible/to maintain code.
...
-3
votes
1answer
50 views
Python Syntax Format
Since I am new to programming, I just want to understand the format the built-in functions is represented in the documentations. This is the one from python
bytearray ([source[, encoding[,errors]]])...
0
votes
2answers
144 views
“with open() as” and indentation
I could not find any official recommended indentation for the following idiom (straight from http://effbot.org/zone/python-with-statement.htm):
with open(path) as f:
data = f.read()
do ...
2
votes
2answers
75 views
Best way to handle dev/test/prod variables in Python?
I'm creating a python module at work, and I have a config file with variables that change for dev or prod (i.e. S3 buckets). What's the best way to do this? Right now I have dicts in config with DEV ...
8
votes
1answer
253 views
Options to handle large (multi-gigabyte) file uploads
How would you implement a very large file upload functionality with a Django application and S3?
In my side job as a photographer, I have several clients for which I have a need to share multi-...
1
vote
1answer
77 views
Accessing thread state from main process [closed]
I am currently writing a Python program with a main process distributing work to a number of worker threads via separate worker queues per thread.
I am now having the problem that the main process ...
3
votes
4answers
386 views
Should I really use all uppercase for my constants?
I am a Python programmer primarily who uses pylint for linting source code. I am able to eliminate all of the warnings except one: Invalid name for a constant. Changing the name to all caps fixes it, ...
0
votes
0answers
42 views
set-up of web-scraping and analysis in python with celery and rabbitmq
EDIT: Is this question too vague, too time-consuming to answer, too easy, placed in the wrong forum? It's my first question here, so I'd like to ask for some feedback so I can improve my question. ...
3
votes
1answer
103 views
Best way to design flows based on operations
This is the problem: I am designing a framework that is basically getting chemical compounds, perform operation with them (or among them) and return results.
At the moment I have a class that holds ...
1
vote
0answers
31 views
Is it appropriate to use docstring `return` and `args` sections to specify HTTP statuses and URL parameters?
I'm working on a web application project which uses Tornado as the web frontend. Currently, I'm in the process of writing up docs and adding docstrings to the code base with Pydoc.
As a web API ...
0
votes
1answer
41 views
Implementing additional function to stack data structure
How would i design a stack which in addition to push() and pop() ,also has a function min which returns the minimums element ? min() must operate in big O(1) time
7
votes
1answer
85 views
Python - Architecture for related instance attributes
I want to preface this question by apologizing for its length, especially the code samples; however, I believe I have included the minimum necessary code to illustrate the differences in approaches.
...
28
votes
6answers
7k views
Why does Python only make a copy of the individual element when iterating a list?
I just realized that in Python, if one writes
for i in a:
i += 1
The elements of the original list a will actually not be affect at all, since the variable i turns out to just be a copy of the ...
2
votes
4answers
199 views
Is colon in python blocks technically necesary?
This is really just a theoretical question by a python newbie who wants to understand more.
I keep forgetting the colon after the block initial statements in python. Those are what I mean:
for <...
1
vote
1answer
61 views
Python Import Order
I am working on a large project in python that has lots of imports.
Some imports are system imports - these are easy, usually just absolutely imported.
Some imports are third-party. These can have ...
0
votes
0answers
31 views
Creating a class factory typish RPG system with SQLAlchemy support
My game will have a class hierarchy like this:
Player:
int level
int xp
list[Skill] skills
Skill:
str name
int level
int max_level
Each player to join the server will get an ...
0
votes
1answer
71 views
Best way to import a large module to use in different modules
I have a python module dataProcessor.py which initialises a large amount of data into memory (approximately 3GB) I want to use this module in different processes which are running simultaneously.
...
-1
votes
2answers
118 views
Assigning instance variables in function called by __init__ vs. function called from __init__
If I need to have a function do some processing in order to initialize multiple of the object's variable (I'm having a hard time coming up with a simple example that doesn't seem weird).
Which of the ...
2
votes
2answers
378 views
Efficiency considerations: nested loop vs recursion
I would consider myself an intermediate Python programmer. One of my recent challenges was creating a list of all possible solutions to a given
Countdown problem.
Without getting into too much detail,...
0
votes
0answers
71 views
Should I pull the language data files of a project from a GitHub repository?
I am currently in a dilemma. I am thinking about downloading a JSON file from a GitHub repo to replace local files. The local files are stored in a folder named lang, which is stored in the project ...
0
votes
0answers
44 views
Maximizing the sum of edges in an undirected graph
Our graph is transitive and bidirectional.
We are given m distinct edges to add to the graph. We define m_k to be the degree sum (over all vertices) after adding a given edge m_i. We then define the ...
6
votes
0answers
69 views
What is the best way to store and manage client <> server <> server and back session information and authorisation?
I have scenario, where I have javascript front-end connected using AJAX communicating with Django-Rest-Framework backend. Users authenticate using JWT tokens. Backend is acting as chatbot and ...
1
vote
1answer
163 views
How to define and share a JSON schema between the front-end and back-end of an application?
We have a mobile app that accepts input into some fields, formalises them as a JSON document and then sends it to the back-end for processing.
We want to agree on a schema for this document that can ...
1
vote
2answers
107 views
Scheduling of parallel I/O-bound tasks (Backup solution)
I want to implement a backup solution in Python where a Backup-Server initiates backups on a number of virtual and physical servers (one server = one backup task). Disregarding the details of the ...