2,205,833 questions
0
votes
1
answer
22
views
How to display names instead of IDs, using Django with React?
I'm using Django with React.
I'm creating a CRUD application for products. My Product table is related to the Category, Brand, Model, Quality, and Supplier tables.
I can save the data, but when I try ...
0
votes
1
answer
32
views
Python Selenium - how to download via execute_script
I made a small app in Python, using Selenium and Firefox, where I want that in response to a click in an anchor element, the file is downloaded instead of opened in a new tab (PDF file).
from selenium ...
Best practices
1
vote
2
replies
47
views
Could this logging setup code be rationalised
Any thoughts on how I could simplify this code a bit, for example is there any way of putting the format string in a root handler so that it is then inherited in the file logs. Just feels like a lot ...
-1
votes
0
answers
49
views
Selenium Python ReadTimeoutError: HTTPConnectionPool(host='localhost', port=53487): Read timed out. (read timeout=120)
It turns out that when I run these instructions in my command line in AWS Ubuntu:
/usr/bin/python3.11 && /home/bitnami/spacy_venv/bin/python3.11 /home/bitnami/htdocs/android_app_selenium.py ...
-7
votes
0
answers
56
views
Need help to troubleshooting my first program [duplicate]
I'm an absolute Newbie (I only started programming this seriously since 2 hours) and I have gotten stuck on my program!
The first and finished part of this program chooses 3 numbers from a list of 73 ...
Best practices
1
vote
3
replies
72
views
Why does divmod() run slower than successive division + taking the remainder?
I tried to optimize my factorization function:
def factorize1(n: int, /) -> Factorization:
"""Return dictionary, where keys are all prime factors of natural n
and values are ...
Best practices
0
votes
0
replies
19
views
Azure Durable Functions Fan-out/Fan-in with Durable Timers
I have Fan-out/Fan-in design that triggers several activities parallelly and waits for all of them before running an aggregator activity:
@myApp.orchestration_trigger(context_name="context")
...
-2
votes
1
answer
100
views
Counting items in column or why is my code only counting one item in the string?
A continuation of yesterday's question.
I need to count how many times a word (gene name) appears on a row (bacterial sample). I needed to see how many double-copied genes there are.
Since yesterday, ...
Tooling
0
votes
4
replies
64
views
How do you efficiently export and process large backlink datasets in Python?
I'm building a backlink analysis tool and need to handle domains with tens of thousands of backlinks.
Current approach:
import csv
def export_backlinks(backlinks, output_file):
seen = set()
...
-3
votes
1
answer
69
views
How to fix json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 9035) without modifying a file? [duplicate]
I am working on a polymarket bot and downloaded historical bitcoin data from bybit. Whenever I try to iterate it I get this error:
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 9035)...
1
vote
1
answer
85
views
Define a type as a union of constants
I have a Python function that accepts a socket.AddressFamily argument.
import socket
def fn(family: socket.AddressFamily) -> None:
...
This works fine. However, intersphinx doesn’t know this ...
-6
votes
1
answer
73
views
Problems in Python with file.read(dateiname) within a function [closed]
I have created a file named file_read_funktions.py. Within is a function defined as:
def file_read(dateiname):
check_datei(dateiname)
open(dateiname, 'r')
inhalt = file.read(dateiname)
...
Best practices
0
votes
13
replies
88
views
Is Python an efficient way to automate View/Table construction for database?
Is it “appropriate” to use Python to automate the creation of certain tables/views in PostgreSQL?
The thing is, some columns have too many unique values, and writing the script becomes time-consuming ...
Best practices
0
votes
3
replies
88
views
__await__: may it be called several times and then wait again?
For iterators, there is a clear protocol: once they are exhausted, they remain exhausted.
It is not allowed to create an iterator whose __next__() raises StopIteration and, called once again, return a ...
1
vote
1
answer
69
views
Vectorising weight average over time
I'm trying to calculate the quality property of a storage tank over time. The quality is the weighted average of the previous period's quality (weighted by closing stock balance) and the current ...