2,204,221 questions
Score of 0
1 answer
12 views
Retrieve parameters of a redirected website on aiohttp
The code below contains a asynchronous def that sends a request to a OAuth2 server endpoint and when the server returns 200, the client is redirected to the given redirect point called redirect_uri ...
Score of -1
0 answers
13 views
Import hook at the AST level
Is there an Import Hook available for hooking into after the source code has been parsed into AST but before it is compiled?
I am looking for a way to keep using most of the existing Python import ...
Score of -5
0 answers
91 views
new to Python and i need help shipping app [closed]
i am learning python for fun, and i am making a simple app for my friend. however i am coding on a windows and he is on mac. what is the best way to make a app for mac from windows. Ive been trying to ...
Score of -3
3 answers
102 views
Python can't find function from imported module - first time creating an __init__.py file
I'm trying to better organize a long program I'm working on. In main.py I have this line: from core import *. There is a subfolder called core and in that folder I created a bunch of modules to ...
Score of -2
0 answers
54 views
Pydantic v2: default a generic Literal discriminator from its type parameter
I have a generic event base where the discriminator is a type parameter so subclasses don’t redeclare kind:
from typing import Annotated, Generic, Literal, TypeVar, Union
from pydantic import ...
Score of 2
1 answer
122 views
How to implement RK45 algorithm for N-body simulation
I am attempting to write a program that simulates the three-body problem using RK45 (or Runge-Kutta-Fehlberg) integration, following the outline given here PDF
I am ultimately trying to use RK45 to ...
Score of -3
0 answers
159 views
QGraphicsScene subclass will not add items which reimplement QGraphicsItem.itemChange, due to diamond-inherited QGraphicsScene subclass
QGraphicsScene subclass will not add items which reimplement QGraphicsItem.itemChange, due to QGraphicsScene subclass which inherits QGraphicsScene twice. This is not allowed in C++/Qt, its the ...
Score of -10
0 answers
136 views
Why cant the input() command let me output more commands? [closed]
Im trying to make a silly "terminal" simulator that has silly things like deleting all of your files if you try to access government secrets, but the var = input("string") command ...
Score of 2
1 answer
83 views
Nested asyncio.timeout(): both expired() return True, how to tell which one raised?
I have a retry loop with a per call timeout inside an overall budget:
import asyncio
async def fetch(budget, per_call):
try:
async with asyncio.timeout(budget) as outer:
for i ...
Score of -5
3 answers
148 views
Can I broadcast with numpy character find
I have an array of potential substrings and an array of full strings. I'd like to know which elements of the potential substrings are indeed found as substrings in the full array.
import numpy as np
...
Score of -3
0 answers
90 views
How Does AWS Lambda and Layers work with a Project that has Subdirectories? [closed]
I'm running into an issue with hosting some code on an AWS Lambda.
I'm trying to run a project on a Lambda with the following file structure:
my_layer.zip/
└── python/ # This folder ...
Score of 3
1 answer
131 views
How I can prevent flickering when I render graphics directly to Linux framebuffer using python?
I am experementing with linux framebuffers in order to display graphics on screen without using wayland or X11.
For that I made a simple script that renders a rectangle upon framebuffer:
import mmap
...
Score of -2
1 answer
167 views
How do I access CGI form variables in current Python? [duplicate]
How do I say the following in the current version of Python?
import cgi
cgi_hash = {}
for key in cgi.FieldStorage().keys():
cgi_hash[key] = cgi.FieldStorage()[key].value
Score of 1
1 answer
106 views
How to express a conditionally required parameter in a Pydantic-validated tool/API schema, without losing the upfront schema validation?
I have a function (specifically an MCP tool built with FastMCP, but this is really a Pydantic/JSON Schema question) where one parameter is required in the normal case, but must be optional when a ...
Score of -4
2 answers
172 views
googletrans - python - Is not translating
I am using the `googletrans` library for the first time to run some tests. I am following the tutorial found here: https://github.com/ssut/py-googletrans
The code i am using is:
import asyncio
from ...