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.

84 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
1answer
694 views

Recommended way to organize and build multiple services for App Engine Flexible Environment with custom runtime

When deploying to Flexible Environment using the default runtime (e.g. python), we just need to specify different app.yaml files with different entrypoint: values. But what would the 'best practice' ...
3
votes
0answers
756 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 ...
3
votes
2answers
370 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 ...
3
votes
0answers
872 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 ...
3
votes
0answers
599 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: ...
2
votes
1answer
102 views

Object attributes as special parameter objects in python

I am writing a library that can be used with some GUI and would like to be able to build an interface where user can see and/or change most of the object's parameters, and also write some of these ...
2
votes
0answers
57 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. ...
2
votes
0answers
98 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 ...
2
votes
0answers
81 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 ...
2
votes
1answer
207 views

Logging an application in Python

Recently I have worked in a small standalone Python console application and have inherited some code from another team. Although some of us have written small Python scripts in the past, none of us ...
2
votes
0answers
222 views

Separate business logic from ORM models in SQLAlchemy

I have a Flask application with tens of complex models, almost all of them related to each other. A simple pseudo-schema of some of them: +----------------+ | FoodGroup | +-------+--------+ ...
2
votes
0answers
90 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'...
2
votes
0answers
83 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 ...
2
votes
0answers
700 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 ...
2
votes
1answer
1k 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. ...
2
votes
1answer
111 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 ...
2
votes
0answers
44 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 ...
2
votes
0answers
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 ...
2
votes
0answers
796 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 ...
2
votes
0answers
636 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 = ...
1
vote
1answer
26 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 ...
1
vote
0answers
97 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 ...
1
vote
0answers
47 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 ...
1
vote
1answer
37 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. ...
1
vote
1answer
115 views

Should there not be methods intended to be only called from inside of the package, but from the outside of the class they're defined in?

Note: This is a follow-up to this question on StackOverflow. I have to write a wrapper in Python to an external API, accessible through HTTP. The code is supposed to be publicly available on GitHub. ...
1
vote
0answers
29 views

Identify specific methods and their parameters in source code

I have two source code files (one in java and the other in python). Certain methods in the java file have references to the python file using the PythonInterpreter, e.g. execfile("hello.py"); or it'...
1
vote
0answers
1k 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 ...
1
vote
0answers
101 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 ...
1
vote
0answers
46 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 ...
1
vote
0answers
352 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 ...
1
vote
0answers
408 views

How to utilize Fat Models practice for Django and Django Rest Framework

I would like to know how experienced programmers and software engineers balance usage of Django's fat models approach against DRF views. In practice, my experience revolves around configuring DRF ...
1
vote
0answers
802 views

How to improve detection of Probalistic Hough-Lines-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 ...
1
vote
0answers
79 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 ...
1
vote
0answers
90 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 ...
1
vote
0answers
1k views

Python inheritance/import - parent file imported modules, should child import too or thru parent?

My apology if this question is already answered & accessible through search - not quite sure how to phrase this particular query. So, here's scenario & question: File a.py imports several ...
1
vote
0answers
225 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 ...
1
vote
0answers
53 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 ...
1
vote
0answers
99 views

How to re-use a very small Python utility across different applications?

I have a very small utility that has proven itself very handy across a multitude of applications. The utility itself is less than 50 lines of code and is its own Python module, and a number of ...
1
vote
0answers
165 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 ...
1
vote
0answers
66 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 ...
1
vote
0answers
1k views

Calculating uncompressed file size without uncompressing file in zlib

I am writing a python program which parses zip (currently only zlib, using DEFLATE compression) files and verifies the correctness of their headers and data. One of the things I'm trying to achieve is ...
1
vote
0answers
150 views

Code structure with MongoDB in python

I am new to MongoDB and python. I know how to make basic use of pymongo in order to manipulate documents. I am having trouble finding how to create some structure or governance in what gets inside ...
1
vote
0answers
42 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 ...
1
vote
0answers
263 views

Need to add websocket support to a single page that's running a wsgi service

Current setup. I have a legacy ERP system (Thoroughbred) and i then have several in house applications (CRM, WMS) and a website that interact with it via an xml server and straight ODBC connections. ...
1
vote
0answers
83 views

Improve communication between controller and trackers in a Twitter fetcher tool using RabbitMQ or Apache Flume

I've been working for a time with some researches developing a tool to fetch tweets from Twitter and process them in some way. The first prototype "worked" but became a pain as we used sockets to ...
1
vote
0answers
4k views

Best practices to parse a log file using Python

I'm writing a Python tool to parse a log file from game server. The log file is of format: ms:classname::id::method::arg1::arg2.... There are a lot of classes, and a lot of methods for each class, ...
1
vote
0answers
729 views

Why does pkg_resources not find bloom in my virtualenv?

I'm trying to hack on the ROS bloom build system (https://github.com/ros-infrastructure/bloom). After I've made some edits, I build it and install it to a virtualenv to test using python setup.py ...
1
vote
0answers
114 views

Inheritance and constricted referencing

Let's say I have BaseA and BaseB classes. BaseB can have to several references of BaseA instances. Now, we have two other classes, DerivedA and DerivedB that respectively inherit from BaseA and BaseB. ...
1
vote
1answer
1k views

Web application / Domain model integration using JSON capable DTOs

I'm a bit confused about architectural choices for the web-applications/java/python world. For c/c++ world the available (open source) choices to implement web applications is pretty limited to zero, ...
0
votes
0answers
35 views

Maintaining data: Unprocessed data, processed data, and results from processed data

I have built a python process which automates some portion of handling support tickets in Salesforce. I use selenium to extract all open support tickets and stores them in an archive. From that list,...