Questions tagged [python-3.x]

Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008.

Filter by
Sorted by
Tagged with
-2
votes
0answers
25 views

Optimization for data storage

I'd like your advice on the design of my application. I use websockets to receive new data and the request module to retrieve older data. Then I use pyqtgraph to display data and tables etc with pyqt5....
-2
votes
0answers
34 views

Should I do database CRUD operations in classes instead of main.py?

This is an app design question. I'm new to OOP coming from writing functional monolithic scripts in Powershell as a windows server admin and need some help on best practices as I begin with OOP. I am ...
0
votes
1answer
47 views

Class Design question concerning adding a new “DRAFT” state to an object

We have some entities in our code: -"View" and View has some attributes and also contains one or many "SubViews" -And each "SubView" has some attributes and contains one or more "Tweet" entities. ...
-4
votes
1answer
61 views

Best practices when interfacing Python and C code

I have a piece of code that I developed in an academic context for which I would like to build a nice frontend. My approach to coding has been very academic to this point (read: I made stuff up as I ...
1
vote
0answers
32 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":...
0
votes
0answers
30 views

How to properly structure a Game Server (using Python3 socket)

I'm having trouble how to structure a proper Game Server using python3 socket library. My game is a serverside game, where the client send basic commands to the server, which is interpreted and run by ...
-2
votes
1answer
49 views

Finding the domain(s) of variables in a Linear Program using the constraints? (Constraint programming/Linear programming)

Forgive my jargon , as I'm not very familiar with Constraint Satisfaction Problem(s) or Linear Programming procedures (For eg: Presolve) I have very trivial constraint set from variables of ...
-2
votes
1answer
84 views

Is Python's Django WebFramework good to design Expert System as a Web App?

I hope everyone is good. Well, I am at the end of my degree BS (Software Engineering), and in the third Phase of my Final Year Project named as 'Test Phase'. My Project is to build an Expert System ...
-3
votes
1answer
131 views

Python Code Design - How should I have used OOP?

Edit: My main question is how would you structure and design code to accomplish the project I describe below. Please try and think of this as a technical interview question and you have to describe ...
-2
votes
1answer
134 views

Proper program structuring in Python

So, recently I have been doing a lot of programming in Python. I have noticed that my programs can be somewhat hard to read. I usually have one main class which does everything, sort of like this: ...
2
votes
1answer
37 views

Event Handling in Pygame

I am working on setting up a game in pygame and I've noticed that there isn't really a lot available for event handling. Basically, pygame has a queue of events that you can pull and iterate through ...
-1
votes
3answers
194 views

Birthday Paradox, Analytical and Monte Carlo solutions give two systemically slightly different results [closed]

I was doing a Monte Carlo implementation of the Birthday Paradox in Python and I wanted to check if the results where the same as in the analytical implementation of the same problem (As they should ...
1
vote
2answers
81 views

Python subclassed methods with additional arguments

Given the following structure where I want a method with a common name for each class, but each derived class needs an additional piece of information in order to form the appropriate result. ...
0
votes
1answer
54 views

How to expose multiprocessing python application to support invocation from command line and web

I have a python forecasting application that, for a given Entity, executes a fbprophet model multiple times varying the hyperparameters for each execution while tracking the best fit across the runs. ...
2
votes
2answers
231 views

What is the difference between unit testing and handling exceptions

I have spent two full days now trying to understand the difference between unit testing and handling exception, but I can't get it. Things I have understood (or I think I have): Unit testing tests ...
0
votes
0answers
103 views

How to design realtime deeplearning based application for robotics using python?

I have created a machine learning software that detects objects(duh!), processes the objects based on some computer vision parameters and then triggers some hardware that puts the object in the ...
-5
votes
1answer
129 views

Upload fingerprint from android/ios to cloud

I am working on a project to use fingerprint to authenticate the user. I don't want the authentication to be device specific. Hence want to upload the user fingerprint to cloud. I do understand that ...
0
votes
0answers
501 views

What is the fastest way to parse variable record binary files in Python?

The Python Binary File Parsing Deep Dive Intro I'm an electrical engineer by trade, however my job has a lot of software engineering overlap. Recently something I've been working on is a Python ...
-3
votes
1answer
307 views

Why do people keep reusing superclass names in their subclasses?

In my project, I found one of the project's classes reusing the same name as an official one. For example: from django.db import models class Model(models.Model): class Meta: abstract =...
1
vote
1answer
72 views

Api limit access to subscribers only

I have a vanilla php api(on a vds) and I want to make data coming from that api available to a few clients that are using a python app that's also written by me. That python app is running on my ...
2
votes
2answers
99 views

Having tasks that can be ran individually or “in trees”, and each task can be blocking or non-blocking

I'm creating a framework that needs to execute certain tasks, I'll use building a car as an example for this. So, an individual task could be something like weld metal or screw bolt. But there are ...
0
votes
1answer
63 views

How do the (presumably sync) loop runners launch the async event loop?

Where is the implementation interface in Python documented that allows the async loop runners (from trio, asyncio, curio) to start the whole shebang? We know that sync functions cannot call async ...
0
votes
3answers
102 views

Options for parsing input that will include math

I'm working on a program that takes in user input which often includes things like math.sqrt(), imaginary numbers, multiplication, division, and similar (basically, standard math plus imaginary ...
4
votes
1answer
212 views

Is using getters to exchange information between objects acceptable?

Suppose I have the following Character, Potion, and PotionType classes: class Player: def __init__(self, name: str, health: int, mana: int): self._name = name self._attributes: ...
-3
votes
1answer
135 views

what is a difference between resource and source in programming [closed]

I had a question for separating my python project files. What is a difference between "resource" and "source" in programming? When I should use "resource" separation and When I must use "source"?
3
votes
3answers
1k views

What is the safe way of using keyword-only arguments?

Keyword-only arguments are arguments that can only be supplied to a function by keyword. In Python they are defined by a single asterisk in a function's signature. For example: >>> def foo(...
2
votes
1answer
68 views

Why doesn't Python3 optimise variables assignments

I just read this SE question about parameter optimisation. I wondered if Python3 bytecode compilation does the same optimisation and this appeared not to be the case: >>> def f(a): return 2*...
-1
votes
1answer
79 views

How to read user input and at the same time execute periodic commands

How would I go about prompting user-input, while at the same time running timers, to periodically execute automatic functions. Pseudo-code to illustrate: while true { if input() OR timer(10) ...
-1
votes
1answer
85 views

Can i be two places at once in python cycle

I'm doing this in python, in case that changes anything. I'm trying to make a lamp/bit go 1-0-1-0 until the user says "okay" the "okay" should indicate that the user has found the lamp/Bit IRL. Now ...
3
votes
0answers
96 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
33 views

An approach to send the contents of a file on the server to the client in real-time

I have a relatively simple front in good ol' JQuery, that makes a POST Request to a Flask Python web server, that runs a Python script using the subprocess module. Here's the whole route for ...
1
vote
1answer
258 views

Does the fact that random.sample(seq, 1)[0] === random.choice(seq) mean that both functions should have the same precondition on seq?

I've read https://bugs.python.org/issue33098, which is about the following behavior of Python 3 a = {'1': 42, '2': 84} # keys are str on purpose, c.f. the issue import random random.choice(a.keys())...
6
votes
1answer
2k views

Convince people not to use an “end-of-life” Python 3.X version

Context At my company, we have a major Python package which is written in Python 2. We are now planning to migrate it to Python 3 (we don't care about keeping it Python 2 compatible). I am a junior ...
2
votes
1answer
94 views

Is it considered bad form to call `next` on the input sequence of a list comprehension?

I want to extract lines from a stream that are preceded by the character L. The list comprehension below does the job, but calls next on the stream inside the comprehension in a way I've never seen ...
170
votes
23answers
24k views

Programming cleanly when writing scientific code

I don't really write large projects. I'm not maintaining a huge database or dealing with millions of lines of code. My code is primarily "scripting" type stuff - things to test mathematical ...
0
votes
2answers
113 views

What is list of arrays in python?

I read in the Python time complexity page: A deque (double-ended queue) is represented internally as a doubly linked list. (Well, a list of arrays rather than objects, for greater efficiency.) Both ...
2
votes
3answers
235 views

Should I test the debug branch of my code in a unit test?

Lets say I have a function that gets a list of what files to send that are later send over a socket to some other pc. Now usually I keep track of what files have been sent and don't send these files ...
1
vote
1answer
723 views

How are list elements accessed in python internally?

Like if I want to access an array element in C it's implemented like this: For example: If a = {0, 1, 2, 3} is an array if I want to access index number 2 I will write a[2] and the formula that is ...
3
votes
0answers
842 views

Project structure with git submodules with common dependencies

I have two (and more in the future) Python projects that I'd like to package into a global package in order to import its modules and use them in another external projects in the future. This is how ...
0
votes
2answers
135 views

Difference between interaction log and “debug” or “application” log

Let's say I need two logs coming out of my application. One is for debugging issues and making sure the application runs correctly and the other is used for user statistics and general analysis of the ...
4
votes
1answer
188 views

Split ORM module without creating cyclic imports or side-effects

Preface I have an ORM library for a relational real estate database. The used framework is peewee. The library contains ~60 models, each representing a distinct table. The models represent a (pre-...
1
vote
2answers
438 views

Enforce strict naming of multiple arguments

I have some questionnaire data in CSV files for different projects. I created a function that takes a specific subset of columns and calculates aggregated values. The problem is that across these ...
2
votes
1answer
328 views

Speech to text - action - text to speech: architecture/logic. Is there a better way to build my robo-player?

I have decided to start a personal project using Python since I have used it for several years now and I would like to know if the approach that I have considered is good or not. Description It's ...
3
votes
0answers
86 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 ...
1
vote
2answers
200 views

Actions that can have individual cooldowns or a “group” cooldown

I'm creating a game (well, a plugin) where each player has a list of skills, each of which has an unique type object, each of which has a list of actions that need to be ran when a player executes his ...
0
votes
1answer
510 views

Should I produce output with yield or stream.write in Python 3?

I am working on a Python 3 program that will among other things write data to text files in a number of formats. I have one function per format, generating the data to be written. I see two possible ...
2
votes
5answers
7k views

Why are Python sets and dictionaries not ordered by default?

I understand the difference between ordered and unordered sets, and I understand why for many purposes, we don't need ordered sets. But all set operations are still possible on ordered sets, and sets ...
0
votes
1answer
269 views

MySQL linter: Letting an installed python package Integrate with a user-written python module

I'm working on a new style of database migration system that is coming along nicely. There is one last aspect of it that I want to finish, which is to enable MySQL linting. For background, this is a ...
0
votes
2answers
99 views

Efficiently computing and storing global state

I am working on a graph problem which is special in the sense that the nodes are computed only when required. This is because the graph is so huge that the entire graph won't fit in memory. So, in my ...
0
votes
2answers
362 views

Dynamically choose whether to use __slots__ in a class

I've got a generic container class: from typing import Container, Generic, TypeVar, NamedTuple import sys fixed_typing = (sys.version_info >= (3, 6, 2) or (3, 5, 3) <= sys....