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
-3
votes
0answers
14 views

Better way to process huge files

I have a huge csv file and I have to process that file and do some data manipulation. Right now I'm reading/loading the file in buffer and then doing the data processing work. I find this approach ...
0
votes
1answer
64 views

What are the benefits of not checking function arguments in python?

I'm trying to understand what are the benefits of the fact that python defaults to not checking function arguments. For example: from some_module import my_function my_function(some_argument) # ...
-2
votes
0answers
41 views

Best way to iterate over sparse dataset

I have a set of elements that I need to iterate over as part of a modeling workflow. The elements exists over a set of dimensions (i, j, k, l). Due to model constraints, most of the elements within ...
0
votes
1answer
46 views

Trying to figure out the optimal selection based on a set of rules

Background: We have software that displays different products to the user Problem: With a given set of rules, determine which is the primary product we should show the user. These are images. We are ...
-5
votes
0answers
63 views

How does Backtracking work in this Sudoku solver? How is the next “path” chosen

I have this solve function. From my understanding the backtracking part of this algorithm is the line after the recursive solve(). I would think that it would leave 0's in the final board. Say if I ...
-5
votes
0answers
51 views

Example Uses of Python Recursion in Professional Development Work [closed]

The phrase "real-world" examples is ambiguous so I left it out of the title. I want to know to what extent recursion is part of the daily toolkit of professional Python developers. Obviously ...
0
votes
0answers
66 views

Python circular dependency

I have two classes AST and ASTNode for working with some tree-like data. Both these classes have networkx graph as a field and a node id (integer). For AST this id refers to the root of a tree. These ...
-5
votes
0answers
84 views

How to call a list of REST APIs in huge volume to get optiomal performance? [closed]

I have written a Machine Learning based microservice in Python and using Flask for the REST endpoints. There is a need to pull data by calling around 4 REST APIs. But the call to the 2 APIs is going ...
0
votes
1answer
25 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(...
2
votes
1answer
81 views

Converter implementation in Python: class versus module?

I've written a little library that uses the builtin ast library to convert between functions, docstrings, argparse .add_argument, classes, and [soon] more. Stubs look something like this, with ir ...
12
votes
1answer
4k views

Is it possible/advisable to combine unit testing and integration testing?

I've built a Python script that consists of about 20 functions that extract data from MySQL via .sql files (I'm currently trying to learn SQLAlchemy ORM), do something to it and then put it back in ...
-5
votes
0answers
50 views

How many ways are there to reference Python objects and what are they?

I'm trying to write a script that would take a raw text and return if the given Python object is in it or not. In this context, 'a Python object' is anything - variables, functions, classes, and ...
1
vote
1answer
95 views

When modules written in different languages interact, is exchanged data always serialized?

I have module written in Python and I would like to write function in e.g. Go but problem is that data needed for computations is often more than 100MB. My question is: is data always serialized and ...
-4
votes
1answer
102 views

What things should you consider when porting software from python to c++?

Suppose you have written a prototype for an application in python, now you want to rewrite it in c++ for speed reasons and to make a real software out of it. What are things to consider before ...
-2
votes
1answer
61 views

How the basic structure of a simple messaging app works?

How the messaging apps works? What is the Basic algorithm of it? I tried the following method to make a messaging app. I enters message Message converts to a text file Text text file uploads to the ...
-3
votes
2answers
88 views

Should I use Flask w/ Javascript OR a Javascript UI that calls a Flask / Connexion API?

I recently wrote a data management tool in Python & SQLAlchemy. Now, I need to put a web UI on it. While I want to start small, there is some need for interactivity, like drag and drop in tables, ...
-3
votes
1answer
33 views

Python BeautifulSoup: Function to stop a soup.find_all_next() at an exact point in the soup?

this is my first post here on stackexchange. I am new at python and just started a month or two ago. The project I am working on is a webscraper to take market data off of marketwatch.com. The ...
0
votes
1answer
89 views

Is dynamically hiding specific parts of the input data passed to a function pythonic?

I have a design question regarding "dynamic information hiding" vs static typing. I have for the following python code class RuleInput: attr1 = ... atrr2 = ... ... def ...
1
vote
1answer
58 views

Strictly only importing modules in subdirectories: is this a good rule?

I'm making my 1st official project. It's written in Python, is open-sources, and I'd like people to be able to freely and easily fork and modify the code. The project name is "shelf" and the ...
-3
votes
1answer
77 views

Sharing data among websites

I manage one middle sized website that uses Flask and PostgresSQL on the backend and some JS with Angular and Jinja2 templates on the fronted. Now we're going to create a second website that will be ...
1
vote
5answers
171 views

When to extract boolean conditions into their own function?

I commonly use a boolean condition/variable when it's something too big or complicated and takes too much space by itself inside ifs - basically to avoid repeatability and thus improve readability. E....
0
votes
2answers
63 views

User-friendly parameter parsing from yaml

Problem I have designed an evaluation tool (in python) and need some help to make it more user friendly. The tool requires ~100 (nested) parameters, which it gets from a yaml file and stores ...
-4
votes
1answer
46 views

Keeping JSON in database

I'm trying to create web app(flask or django-rest) that would scrape some data and save it to JSON so that it can be viewed in the frontend (VueJS). I'm wondering if it is better to save the scraped ...
-4
votes
1answer
36 views

Dynamically assign attributes to objects from outside

In python the following code works perfectly fine. class Table: pass table = Table() table.fruits = ["apple", "orange"] But as soon as we check it out with some kind of ...
-4
votes
1answer
53 views

Should I use interfaces in Python (so my code will be more testable and following good practices)?

I've never coded in Python. In languages like C# or Java a lot of people write interfaces for (almost) every class so the code can be more easily testable (by implementing IoC) or other reasons and is ...
-1
votes
1answer
47 views

Preventing name collision between user-defined modules within a framework

I'm a contributor to a framework that's designed for producing synthetic data. The system allows the end-user to create custom data generators and load them into the framework. Currently we store the ...
-5
votes
1answer
67 views

Is it possible to derive a test suite to achieve 100% path coverage? [closed]

Here is an example with the function: Examining this I believe that it is possible to achieve 100% path coverage. My understanding of path coverage is that you need to design test cases such that ...
7
votes
3answers
202 views

Is a subclass Liskov Substitutable if it disallows the same invocation of the constructor in the child as in the parent?

Say, I have two classes: class FTPClient: def __init__(self, host, port): self._client = FTPDriver(host, port) ... class FTPSClient(FTPClient): def __init__(self, host, port, ...
1
vote
0answers
97 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 ...
6
votes
5answers
511 views

Is it a good idea to start a function with a bunch of assert statements?

Sometimes when I look at other people's code I see functions that make a bunch of assumptions about the inputs but do not explicitly assert their assumptions. For example, look at the code below: def ...
-1
votes
2answers
133 views

When should I use a database instead of a list? [duplicate]

New to Python and all things database related. Wondering when I should consider using a database and why? I have what is essentially a list of objects that is around 30000 lines long. I'm developing a ...
0
votes
1answer
165 views

What is the space complexity of a Python dictionary?

If python dictionaries are essentially hash tables and the length of hashes used in the python dictionary implementation is 32 bits, that would mean that regardless of the number of key-value pairs ...
-1
votes
1answer
43 views

Resolving Dependencies and Incompatibilities Deterministically

Problem Description I'm working in Python and I've been having a problem designing something to handle the following (abstracted) system: I have some objects (lets call them Nodes) that can be in ...
0
votes
1answer
114 views

Mixing IoC container use with “poor mans” DI

I'm finding the use of IoC containers to be quite the shift in my application design, and its for the better. I'm using a framework called injector that aims to mimic (albeit not entirely) the Guice ...
1
vote
2answers
63 views

Best way to enforce variable has certain values using enum in Python

I have a string variable named status in my code that can take on three values "Starting", "In-progress", and "Complete". A friend of mine said it was good practice to enforce that status has one of ...
-4
votes
1answer
51 views

Question about the tutorial purgatory in coding path

Dear all the programmers and overflow friend, First, I want to say thank you to stack overflow users for helping me finish 20% of my PhD project since last year (using python to draw some technical ...
4
votes
3answers
161 views

Approach for updating status of a function

When I call a function, I want to receive updates when the function reaches some milestones: def do_something(): start_with_something() # update for x in iterate_something(): # ...
1
vote
0answers
31 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 ...
-3
votes
1answer
48 views

What is the rule for making functions private in Python modules?

I was wondering what's the principle behind it, and whether I should treat all functions from module that are not used anywhere else at the time as private, and mark them with underscore prefix so ...
0
votes
1answer
39 views

What's a proper way to call a chain of methods that modify an instance attribute?

I've got an Algorithm class whose responsibility is to find if a given word is in a list of words. As part of doing that, the algorithm first has to lowercase the words, remove punctuation, and ...
4
votes
2answers
416 views

What's wrong with using a Singleton?

I'm working on a Python application in which there are two Singleton classes: App and Configuration. The former seems straight forward, only ever instantiate one App instance; the latter seems ...
-1
votes
2answers
73 views

Is it possible to have a function executed when a specific exception is raised anywhere in the program?

I want to add some custom retry logic to the AWS sdk (but this isn't specifically about that). So whenever it throws a specific network exception it waits and tries again and whenever it throws a ...
0
votes
0answers
29 views

How to approach the lack of labels variability in a dataset for a RNN model?

I'm working on a quality air index model prediction from certain city. I have a dataset composed of hourly pollutants readings (5) from up to 24 basestations. Not all basestations can read all 5 ...
-2
votes
1answer
53 views

Designating a pin header and a GPIO

I have an Acconeer XB112 breakout board and an XM112 radar module. It all works just fine per the Acconeer documentation and tutorials. Now I want to modify some of the code to output to a GPIO. ...
1
vote
1answer
40 views

Scraper in separate repo from visualization component?

Let me explain my thoughts about architecture of the project I'm working on. The project code repository consist of: Scrapy component - of course it serves to scrape data, process it and calculate ...
-1
votes
2answers
82 views

How to Maintain Rarely Used Scripts

I come across the need to do a lot of one time scripts (related to API evaluations, data extraction, experiments etc.) that have the potential only to be used very rarely in the future. These could be ...
-2
votes
1answer
71 views

Depending on fairly big modules to do just a simple operation

So I have a website which does a bunch of different stuff, more importantly, it allows the user to upload videos. Now unfortunately videos are a bit annoying as they need a poster img to display ...
2
votes
1answer
89 views

Python: Return or update object

Firstly I am new to Software Engineering and my last question was closed. I am doing my best to ask relevant questions and improve. If you are going to down vote my question I'd really appreciate if ...
-4
votes
1answer
60 views

Is it better (from a maintenance perspective) to dynamically construct complex SQL queries using Jinja or String concatenation? [closed]

Two possibilities. Which is better, with respect to readability, maintenance and clean code: SQL injection can be disregarded. Constructing complex parameterized sql queries using python string ...
-4
votes
1answer
31 views

How would I authenticating a Software Plugin with Username/Password using REST?

I'm developing my first Python plugin for a 3D application. What I'm looking to do I would like users who've purchased a subscription to the plugin from my Wordpress/WooCommerce web site to log in ...

1
2 3 4 5
34