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.

Filter by
Sorted by
Tagged with
2
votes
5answers
342 views

Detect frequency pattern in a list of dates

I have a list of dates in which a certain event happened. Taking into consideration that a particular occurrence of the event can: Be a one time thing or Be part of a periodic series, which happens ...
-1
votes
3answers
403 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 ...
3
votes
2answers
209 views

Can Time be a Primary Actor in the Hexagonal Architecture?

I really like the fundamental principles behind the Hexagonal Architecture (Ports and Adapters) and I have mostly applied it to my system/application. There is one thing that I wasn't able to ...
1
vote
2answers
87 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. ...
-1
votes
2answers
113 views

How to decide if a global variable is used inside or outside a function in Python?

In Python variables that are created outside of a function are known as global variables. However to create a global variable inside a function (a local variable), you can use the global keyword. My ...
-6
votes
1answer
116 views

While loop definition in python

My question is about a use of while loops that seems very abstract to me. I understand a while loop like the first one (one which has a clearly defined statement): num = 1 while num<1: ...
12
votes
1answer
726 views

Why was “self” chosen over “this” for the name of the first parameter of python methods?

What was the rationale for choosing the name self instead of this when defining class methods in Python? Yes, of course, you can name it whatever you want - but the widely agreed-upon name for the ...
-2
votes
2answers
76 views

Do python Objects also store their memory address?

In python documentation, I found that every object has a type, identity, and value. Does this mean that the object also contains/stores their memory address?? Or are they just created at some memory ...
0
votes
2answers
166 views

What is the reason python uses range in for loops?

Is there some philosophical reasoning behind why python uses this syntax: for x in range(1,11,3): instead of, for example, the BASIC syntax: for x = 1 to 10 step 3 If Python is supposed to be more ...
0
votes
2answers
287 views

Should parent classes define methods using attributes of child classes?

I need to extend the parent classes of two child classes by adding shared methods to them. Starting with the initial definitions of the child classes: class ChildA(ParentA): pass class ChildB(...
1
vote
3answers
3k views

what is the difference between Object and Value in Python

I have been trying to find this answer but I could not find the proper explanation Some say that they are the same and others say otherwise I know for a compound object, The object will consist of ...
-4
votes
2answers
456 views

How can I calculate the radius of an arc given by a series of points

Given a series of points, I need to assert that the plotted points form an arc (with a certain level of confidence), and I need to approximate the radius of the arc. For example, the following points ...
1
vote
0answers
73 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 ...
2
votes
3answers
385 views

Algorithm for random weighted boolean shuffles?

I don't exactly know how to phrase the thing I'm searching for in a succinct way, which also made it hard to research. In my application I need a random list of booleans, say of length five. The ...
2
votes
2answers
530 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 ...
-3
votes
1answer
770 views

How to make code runnable on open source code editors like Ace Editor?

For my computer science uni project I'm required to build a web application with an integrated code editor. I believe I can just integrate open source editors like Ace Editor. However, I feel ...
0
votes
2answers
146 views

Code style to keep track of nested objects and data types?

In untyped languages (Python, Javascript specifically) find myself making a lot of bugs / wasting a lot of time because I forget what's in the objects I'm passing around. For example, I forget things ...
0
votes
1answer
141 views

Representing mathematical tree structures using software in a compact manner

In my work I frequently come across systems of interdependent equations. I have contrived a toy example as follows. The terminal values w, x, y and z are given: e(y) = A+B A(y) = x*log(y)+y^z B(y) =...
-3
votes
2answers
95 views

Seeking appropriate design pattern(s) to describe most function-based mathematical problems

I have been looking for a good, general design pattern to implement simple mathematical structures where functions have the following properties: know which parameters they contain, parameters are "...
-2
votes
1answer
77 views

Can a software be developed based on a Juypter Notebook workflow?

I have a workflow process housed in a Jupyter Notebook that uses spaCy to parse text documents. The workflow process essentially reads a text file and returns all sentences containing the keywords ...
0
votes
1answer
60 views

How to set up import main module while developing a Python package

This is a matter of naming, structuring and conventions. I am developing a simple python package. in a directory "PKG" I have 3 files: __init__.py: # import the main module import PKG.main # in ...
-1
votes
1answer
90 views

Not sure what design pattern works better in my case

Currently I have a large ontology like this: There are different categories of variants and each can be somatic or germline. There are more common behaviours between same variants, like somatic CNVs ...
-1
votes
1answer
170 views

Function returning dynamic value [closed]

Imagine you have a chain of functions calls, in which each function is taking the previous function's output as input for the next calculation in the chain. Make an assumption that you are leading ...
0
votes
0answers
104 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 ...
0
votes
0answers
28 views

Building a Feed Handler and Persisting JSON Data to Postgresql

I'm starting a pet project and would like some advice. I need to perform the following: Scrape JSON Data from a REST API Save the Data into my Postgresql table Paginate through the rest API and ...
0
votes
2answers
74 views

Data Collection Web Application Architecture

I am building a Data Collection Web Application with Flask and MySQL Database. It is basically a creating a Bill Of Materials for the organization for a new product. Bill of Material in a form looks ...
3
votes
2answers
97 views

Best practices for testing settings file with many parameters in simulation code

I'm conflicted as to what is the best way to approach this problem. I am writing a simulation in Python, which is parametrized by ~ 50 parameters. I have a JSON file where these parameters are set, ...
2
votes
2answers
111 views

Separating namespaces from files in Python

I'm writing a Python library in which various objects are represented as Python classes. However, the user is not supposed to create instances of those classes directly. Instead, there are a set of ...
0
votes
0answers
2k 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 ...
1
vote
1answer
150 views

Recommended way to setup a python workspace

I have 3 (python) git repositories that I need to work with. One of them is the top level application (packageA), and the other two (packageB, and packageC) are dependencies of packageA. (Note: none ...
6
votes
4answers
747 views

Code reviewing nitpicks for readability [actually for DRY]

I was doing a code review today and noticed that the code would work but could have easily been made more readable. The example in particular was roughly as follows: def group(x): GROUP_ALPHA = (...
4
votes
3answers
2k views

Interfaces in Python, multiple inheritance vs. a home-made solution

I am writing a Python framework. In order to ensure a class has some properties, I make base "interface" classes like: class BananaContainer: def __init__(self): self._bananas = [] @...
2
votes
1answer
93 views

How to increase test granularity without modifying the public interface

First of all, I'm aware that in python nothing is really private but let's assume that we can stick to using the leading underscore to indicate that something is private. I have a module consisting ...
1
vote
2answers
77 views

In python, what or who is character encoding information for?

If you go to www.htmlbasictutor.ca/character-encoding.htm you will find the following description of character encoding. Character encoding tells the browser and validator what set of characters to ...
2
votes
0answers
58 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-...
3
votes
1answer
616 views

Managing error code and error message mapping

As part of a game engine I am writing in cython, one of the challenges I am facing is creating a consistent interface for error handling that works at the C and python levels of my code. I am ...
1
vote
1answer
110 views

Appropriate design pattern for developing rules and outcomes [duplicate]

In the exercice i´m developing bellow, i´m applying the chain of responsibility pattern. The pattern works correctly but i don´t think it's the best approach. I think the rule design pattern should be ...
44
votes
7answers
9k views

Why is the worst case for this function O(n^2)?

I'm trying to teach myself how to calculate BigO notation for an arbitrary function. I found this function in a textbook. The book asserts that the function is O(n2). It gives an explanation as to why ...
1
vote
2answers
3k views

REST API Input Validation Strategy

I am implementing a REST API and need to validate the JSON API inputs for the CREATE and UPDATE endpoints. The goal is to send a 400 error prior to doing any processing if the inputs are not valid. ...
0
votes
3answers
295 views

Is using pytruth considered Pythonic?

I recently found Googles pytruth package. I am very used to pytest and I am wondering what the value of the way less commonly used pytruth is. The only reason why I didn't directly discard it, is that ...
1
vote
1answer
151 views

mongodb queries architecture - resolving lots of nested referenced objects

I have an angular 8 application, with a Python + MongoDB API on the backend. At present, I have 4 collections, namely: Users, Tasks, Companies and Groups. All of these resource types are retrievable ...
3
votes
2answers
471 views

What is the best way for transferring large datasets between an old java app and a python app on the network?

I am working on a machine learning project at the moment which requires me to transfer the data from an old Java app(which is also the custodian of the data in current paradigm) to a python service ...
3
votes
0answers
132 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 ...
-3
votes
1answer
309 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 =...
-2
votes
1answer
40 views

Should a CLI wrapper specify function defaults?

In my code let's say I have a function which does most of the work: def compute(x=3, y=5): ... And I have a CLI wrapper program using argparse. I intend end users to use the CLI program and not ...
0
votes
2answers
90 views

Module with globals or Class with attributes?

Currently I'm working with a lot of modules where the original developers used global variables to control states and to exchange important information between functions, like so: STATE_VAR = 0 def ...
3
votes
2answers
365 views

Is there a name for this programming pattern? [closed]

A commmon pattern I've noticed in my Python code follows this simple structure: value = get_val_from_thing() value = mutate_that_val(value) I find myself first grabbing some specific value(s) from ...
3
votes
1answer
1k views

Using Null/None/Nil vs empty data types

This question is more coding style related which is why this question is asked here. I'm new to Python, coming from PHP. I've been looking through Python style guides & code examples, I've ...
0
votes
1answer
89 views

Sending a function via tcp in python [closed]

Is it possible to send a funtion or even just code via TCP in python (it is very possible this question is rediculous I have no idea what I'm doing)
2
votes
1answer
114 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
3 4
5
6 7
36