Questions tagged [python]

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. Python is general-purpose and thus used widely, from the web to embedded systems.

124 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
203 views

Fortran-Python Interface

Disclaimers: This question is reposted from SO upon SO user's suggestion to put it here since there is no specific code in question. This question is a subset of my larger theme of Fortran ...
user avatar
  • 325
4 votes
0 answers
1k views

Python and C++ repository structure

I'm refactoring the directory structure of a large Python repo that has a few dozen C and C++ files littered throughout. Is there a suggested architecture for a Python package that contains C/C++ code ...
user avatar
4 votes
0 answers
1k views

Calculating the multiplicative inverse of a number in a Galois field

I was told to come here from Stack Overflow because I was "looking for an algorithm". I'm trying to implement it in Python, but there is nowhere on the net that gives a straightforward way for ...
user avatar
  • 247
4 votes
0 answers
1k views

How to Use Python as a "Macro" runner for a C# Application

I am working on an application that the user may wish to automate some features of (but we don't know what at the moment) I would like to provide them some kind of scripting interface so they can play ...
user avatar
4 votes
0 answers
1k views

Structuring a multi-language project?

I'm working on a project which involves writing code for multiple devices, each in its own language (in particular, Arduino and Python). I want to contain the entire project in a single directory, but ...
user avatar
  • 141
3 votes
0 answers
69 views

How to structure python modules/packages according to dependecy inversion

If I am working on a project, say it has this file structure: car/ body/ __init__.py doors.py bonnet.py engine/ cyclinderhead/ __init__.py pistons.py ...
user avatar
3 votes
0 answers
229 views

Architecture and Security in a Web/Native app while generating PDFs

I am trying to make a system where a user can view/download his statements (say salary slips). The user will have ability to download PDF versions of these statements and can also save them to Google ...
user avatar
3 votes
0 answers
95 views

Can/Should I make an automatic installation of new python libraries after a git pull?

Imagine the following situation: I'm working on a python project, and I install the library antigravity with pip. I add the function fly() which uses the library, and I commit and push the changes. ...
user avatar
3 votes
1 answer
211 views

Data processing pipeline design for processing data

I have a use case for which I need to build a data processing pipeline Customer contact leads data coming from different data sources like csv, data base, api has to be first mapped to a universal ...
user avatar
  • 139
3 votes
0 answers
109 views

Python3: How to change the design of a class hierarchy to improve access to objects there buried?

I asked this question already at stackoverflow together with a serialization related part and at codereview for the design part only. Since the design related part receives no answers or comments on ...
user avatar
  • 47
3 votes
0 answers
93 views

Software design strategy for a machine learning tool that outputs a subset of the text input (Information Extraction)?

Let's say I have thousands of pdfs that are each about 30k words written in conversational English. In each of the pdfs there is a name / names of a person/people who snowboard. There are also many ...
user avatar
  • 39
3 votes
0 answers
66 views

How would I identify a gap in a set of curve data, and get its value?

I have a set of 2-D data (x,y) and it produces a set of curves, and sometimes the set of curves do not overlap, and there is a distinct separation between the groups of curves, how would I identify ...
user avatar
  • 139
3 votes
2 answers
529 views

Method object creation in Python data model

I've been reading the article on the data model of Python on its Reference website, and have been confused about this part: When the attribute is a user-defined method object, a new method object ...
user avatar
  • 155
3 votes
0 answers
885 views

How does the Zope Component Architecture (ZCA) relate to Service Component Architecture (SCA)?

I'm very new to the principle of Service Component Architecture and Zope in general, but the more I look, the more ZCA seems to be a good solution for a certain class of problems I often encounter. I ...
user avatar
3 votes
0 answers
800 views

The Python module-as-singleton hack

I've seen (and once used) this idiom a few times in Python: # At the end of a module: if __name__ == '__main__': main() # or whatever your entry point looks like, this line isn't important else: ...
user avatar
  • 2,618
3 votes
0 answers
672 views

Gevent - Make blocking calls non-blocking

I have the blocking code shown below. Is calling monkey.patch_all() enough/optimal to make it non-blocking? Does Gevent handle iterations like these? # front page def front_page(): database = ...
user avatar
2 votes
0 answers
71 views

Distributing tasks to several clients

I describe a very very simple scenario. I try to develop a system where many machines can help another one (server). I tried RabbitMQ and Redis, but both don't fulfil all requirements. I have 1-...
user avatar
2 votes
1 answer
177 views

Access control to Django App running on private server

I am a self-learning programmer (with a fair share of python knowledge), and currently a company asked to develop a simple application so that they can track employee expenses (and I thought of using ...
user avatar
  • 121
2 votes
0 answers
113 views

Implementing an iterator vs. looping over a list

I want to loop over a number of rows in a database and I have implemented an object in order to access the rows. Now when using this object I am not sure about the best practice. Implementing an ...
user avatar
  • 129
2 votes
0 answers
395 views

Extensible / Plugin Architecture in Python - overwriting methods deep in the inheritance tree?

Current situation I'm developing a test-framework in python for end-to-end tests for a large ERP application. The AUT (application under test = ERP system) is structured in modules and provides a lot ...
user avatar
  • 121
2 votes
0 answers
4k views

Using a Boolean to cancel thread

I asked a similar question to this on SO, but after re-reading it this morning, I realized it wasn't clear what I'm asking. So I narrowed down my problem and realized it was about a pattern instead of ...
user avatar
2 votes
0 answers
152 views

Packages, a controller class, and coupling vs cohesion

So I'm building my first application, in Python, and some issues have cropped up because of the lack of interfaces (I.e. explicit type declaration) My design involves several homebrew packages, and I'...
user avatar
2 votes
0 answers
1k views

How to improve the detection of Probabilistic Hough Line Transform?

I'm trying to detect a clock hand in a video of an analogue display and extract the value it points to. I'm using Python with OpenCV for this. What I essentially do is: I'm using a Gaussian Blur to ...
user avatar
2 votes
0 answers
47 views

Finding the largest bundle of flagged points

I am currently working to develop a program that takes in an array of 4 columns and around 200,000 rows. Each column represents x, y, z (coordinates), and a flag denoting whether or not this point is ...
user avatar
1 vote
0 answers
50 views

Business rule or repository implementation rule in Clean Architecture

I'm studying Clean Architecture with python and got into this "problem" of choosing where to implement a rule (that I considered a Business Rule, maybe I'm wrong) I have 2 Entities @...
user avatar
1 vote
1 answer
63 views

Dependency resolution of tasks which have crontab information

I want to illustrate my problem statement with a use case. I am building a trading system that acts as a container for deploying trading strategies. The trading strategy comprises dependent tasks. Let'...
user avatar
1 vote
0 answers
64 views

How to build a chatbot that is Open Domain but can intervene on specific intents?

As per my knowledge, there are 2 type of Chatbots- Open Domain and Closed Doman Intent Based. I was wondering how are conversational agents created such that can converse as if they are Open Domain, ...
user avatar
1 vote
0 answers
83 views

Correct structure of a data science project: keeping as functions versus object-oriented framework

I'm working on a data science project that involves data ingestion, cleaning and various aggregations and functions of timeseries equipment data primarily using Pandas. I began the project just ...
user avatar
1 vote
0 answers
39 views

Looking for the right design (pattern?) for my webapp and external APIs intgerations

I'm working on a simple CRM (Customer Relationship Management) webapp (Flask and Peewee ORM) and I found myself in a situation where I believe that I should have used a design pattern that I may not ...
user avatar
  • 11
1 vote
0 answers
57 views

What's the best way to build a Flask API to control and show the status of a program tool I have built?

I've developed a backend project using Python. It collects data from different sources, process the data, and then perform actions with it (for example, store relevant info in a database). To execute ...
user avatar
  • 11
1 vote
0 answers
51 views

Securing Arbitrary Code

I need to run arbitrary code snippets in Python and Javascript on a server. It cannot be run in the browser. I'm thinking of sandboxing the code in an AWS Lambda serveless function. However, I'm ...
user avatar
1 vote
0 answers
126 views

How to isolate a Python script/plugin from the main Python program?

I want to have a Python application - complete in itself - that allows the user to extend it via scripting (or a plugin model) in Python. But I want the script/plugin to have an isolated environment (...
user avatar
  • 663
1 vote
0 answers
40 views

Is there a simpler way to monitor changes to a piece of data, and disallow removing the data from monitoring?

I'm working on an algorithm visualizer for sorting algorithms. Give it a (user-submitted) sorting algorithm, hit run, it'll generate a random list of integers and show you what the algorithm looks ...
user avatar
  • 141
1 vote
2 answers
318 views

add function to input of builtin python logger

For simplicity, assume my application logs only dictionaries. I want to add a step to Python logging for my application to prevent logging any dictionary with the key password, i.e., def clean_log(...
user avatar
  • 111
1 vote
0 answers
474 views

Approach to setup multi-tenant RabbitMQ workers in Python

I'm migrating my current application to multi-tenant setup. Now I've multiple rabbitmq workers to process async job, publish and consume integration events, and other stuffs. I'm planning to use ...
user avatar
1 vote
0 answers
37 views

Optimal package structure - Command Line Interface

I have an ongoing project where the directory structure currently is a mess (github Directory) and I would like to strucure it to eventully create a python package out of it. Below I have outlined a ...
user avatar
1 vote
0 answers
136 views

Combine/Sync Amazon S3 and MongoDB Atlas with Elastic Search

I have many continuously growing (through scrapping) collections in MongoDB Atlas. The documents in each collection follows the following schema: { "source_url": "<some url on the web>", "html":...
user avatar
1 vote
0 answers
84 views

Architecture recommendation for dynamic integration of algorithms/scripts

I am looking for a simple software architecture that is able to evaluate user data using different versions of algorithms. According to my concept, the user is able to upload tabular data via a Web ...
user avatar
1 vote
1 answer
884 views

Django - should I create related objects immediately or on demand?

Let's say you have a ForeignKey MyModel.related_model and this related_model has all fields either null=True or default=something. Like User.userprofile which I use on several places in my project. ...
user avatar
  • 119
1 vote
0 answers
105 views

Making java code usable from other programming/scripting language

We are "extending" a product developed by a third party and working with them on that. There's a small problem though. They have some functions (written in java) that they use in their Android mobile ...
user avatar
  • 131
1 vote
0 answers
48 views

Manage several procedures

I have a software project which grows rapidly in an unexpected way, many customers request similar tasks but with slightly different needs and parameters. I start to dislike my current code structure ...
user avatar
  • 153
1 vote
0 answers
647 views

Putting UnitofWork handler in the Request Model for DDD with Clean architecture?

I'm rearchitecting a system in Python, using SQLAlchemy for the data mapping layer, and the Zope Component Architecture for dependency injection and interface declaration. I am in the process of ...
user avatar
1 vote
0 answers
87 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 ...
user avatar
1 vote
0 answers
116 views

How does the FOSS exception for MySQL connectors apply to code written in PHP or Python?

I have looked all over and can't find clear answers to the following: If I write code in PHP or Python that uses GPL MySQL connectors for PHP or Python - which license applies to my code? That of PHP ...
user avatar
  • 141
1 vote
1 answer
192 views

Optimal Simplification of Transposition Products

I am looking to take a product of a large number of transpositions, and boil it down to a smaller number of products. I have the following code, and would like some input on efficient ways to boil ...
user avatar
1 vote
0 answers
282 views

Does PyPy or Jython run untrusted Python 3 code more secure while still being fast?

I know that one can not securely restrict normal CPython's capabilities to properly run foreign code without allowing it to access some builtins like open() or allowing other kinds of I/O. So I ...
user avatar
1 vote
1 answer
1k views

How to distribute a project with all its dependencies?

We are developing a system for a customer that does not want to allow installation of packages from outside repositories. The project is in Python and defines its dependencies via setuptools; most of ...
user avatar
  • 2,190
1 vote
0 answers
56 views

How do I minimize the number of database queries in a GeoJson API (of countries, and smaller areas) with custom data?

The general version of the question is above - a a little more detail, I am using Django Rest Framework, but am happy for answers to be dealing with the problem in abstract. So, I have data with ~200 ...
user avatar
  • 111
1 vote
0 answers
189 views

How can I improve my websocket server's structure/flow?

I'm building a websocket server in python and I've hit a block regarding my program's flow and structure. Here's what I'm doing at the moment. The program creates a instance of 'server' and listens ...
user avatar
  • 113
1 vote
0 answers
71 views

Writing a container that treats nearly-identical images as the same

I want to create a mapping in Python that will use images as keys, but treat similar (but not identical) images as the same key. I have an approach for deciding which images are similar enough: I ...
user avatar
  • 563