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
-5
votes
0answers
31 views

What is wrong with below regex? [closed]

import re regex = '[0-255]\.[0-255]\.[0-255]\.[0-255]' def check(string): if (re.search(regex, string)): print("Accept") else: print("Discard") if __name__ == '__main__': ...
-3
votes
0answers
28 views

find the number of permutation with length n that the maximum length of consecutive ascending subsequent is k [closed]

We call a sequence of numbers column if all of its members are ascending and consecutive, like [1, 2, 3] and [13, 14, 15, 16]. We also every consecutive subsequent of sequence sub-string. For example ...
-3
votes
0answers
29 views

socket programming reduce connections to server from multiple client [closed]

I want to reduce number of connectivity towards server , suppose I have n number of clients & 1 server & after staring the server I can request from n number of client to single server , but ...
-3
votes
0answers
30 views

Formatting pprint output - specifically hex

I work with lots of huge, nested data structures using Python 3.6.6 and it's very handy using pprint.pprint to output them to text files. However, I'd like all integers in the structure to be printed ...
-2
votes
0answers
17 views

How to send data back and forth between devices in python? [closed]

I believe this is called socket programming, I am trying to send data back and forth between two devices (servers) using Python. Is the approach of configuring two ports (send/receive) on each device ...
0
votes
0answers
17 views

Python thermal live data processing

Looking for guidance on this topic, I have a fairly basic knowledge of python and very little experience working with live data. Currently attempting to work on a project that involves recording ...
-3
votes
1answer
28 views

While loop through mutable lists (phyton) [closed]

So, I have a list with sorted units based in their position. However, through my while loop, I change the position of the units so the order of the list can change too. For example, I change the ...
0
votes
2answers
65 views

How do you handle abstraction when you have no control over the attribute class?

Python, has the library pathlib with the concrete class Path. I have a class called Cleanup, that looks like this: from pathlib import Path Cleanup: def __init__(self, source : Path, ...
0
votes
1answer
72 views

Single responsibility in python [duplicate]

The SOLID principle is supposed to be the underlying framework for object oriented programming. The "S" part stands for: "Single responsibility principle" which in wikipedia is defined as: A class ...
2
votes
5answers
99 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
154 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
77 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
67 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. ...
-5
votes
0answers
42 views

Should I use external Python packages (like NumPy, SymPy, Pandas) when developing a industrial application software?

So, I'm doing my master's degree in Industrial Engineering and for my thesis I will be developing an Open Software (in Python 3) which is to be used by management in order to support decision making ...
-4
votes
0answers
91 views

Pandas select values from one column depending on anther column in Python

I have a DataFrame below but I need to select rows from each code depending on the canceled and order column. Say code xxx has orders [6, 1, 5, 1] and the order is 11. I need an algorithm that can ...
0
votes
2answers
75 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
80 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: ...
11
votes
1answer
558 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
54 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
137 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
102 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
109 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
91 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
60 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 ...
1
vote
3answers
92 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
165 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
73 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
75 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
116 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
78 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
71 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
43 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
87 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
52 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
99 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
18 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
44 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 ...
2
votes
2answers
74 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
99 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
61 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 ...
0
votes
0answers
15 views

django apps updating another apps model\data

I know django apps should be built to be more or less reusable and not tightly coupled with other apps... But I'm struggling to find best practices for having one app update data in another app ...
2
votes
1answer
79 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
680 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 = (...
1
vote
3answers
245 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
75 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
74 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
40 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
140 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
100 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
8k 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 ...