2,205,014 questions
Score of 1
1 answer
84 views
Maintaining a SOCKS connection over ssh in Python
TL;DR: what am I doing wrong with the commented out 'sock.connect'?
I can manage to connect via ssh with the code below (sock.connect and the ssh.connect sock=sock param being commented out) but ...
Score of -8
0 answers
142 views
Is there a better way to filter text? [closed]
I just made this peice of code that filters for bad words
# Saves forbidden words
forbidden_words = ("shit", "fuck", "ass", "bitch")
query = input()
query = ...
Score of -6
0 answers
77 views
limitations of manually constructed RAG prompt [closed]
I am implementing a simple RAG pipeline using Hugging Face Transformers. After retrieving the top-K documents using vector similarity search, I concatenate the retrieved chunks into a prompt and pass ...
Score of -5
0 answers
67 views
How to improve vectorStore and Search in RAG Pipeline [closed]
I am implementing a RAG system in Python and currently use a SentenceTransformer model to generate embeddings and FAISS to perform vector similarity search.
My current implementation is essentially:
...
Score of -5
0 answers
71 views
How can I improve a basic FAISS RAG pipeline [closed]
I am currently learning how to implement Retrieval-Augmented Generation (RAG) systems, and I am trying to understand what a more practical/production-oriented RAG architecture looks like.
I started ...
Score of -2
1 answer
123 views
pandas running notnull() sum() versus count() against the dataframe
I’ve always assumed df.notnull().sum() and df.notnull().count() would return the same value.
Here is a snippet of a code for illustration:
import pandas as pd
data = { 'Name': ['Alice', 'Bob', None,...
Score of 2
1 answer
109 views
How to convert constraints.txt to uv constraint-dependencies section
I have a uv project with a long list of constraints, meaning packages that aren't required, but if something does require it I need to use a specific version or range. uv allows constraints in a ...
Score of -4
3 answers
271 views
How to divide a Python script in a shorter script and a module?
I work with Python in a Jupyter notebook environment. I want to divide a longer setup script in a shorter setup script and a module. Then I want to use the dictionary in the setups script and function ...
Score of -2
2 answers
232 views
Running a Class.method() when that module is imported
Is there a hidden method or some other way that can be used to run some code when a class is defined before it is instantiated?
At the moment the best I can come up with is the example below but it ...
Score of -4
0 answers
167 views
Are Flask HTTP requests from a Jinja template to a Flask api safer than from React or any other frontend framework [closed]
I want to send crypto private keys to the server but am afraid of how hackers can intercept this data. I was wondering if there is a benefit of using Flask with Jinja templates so that maybe it is ...
Score of -3
1 answer
149 views
Modifying a class list results in no modification of the list [closed]
So, I was trying to create a class called Word, wherein the user would enter commands to narrow down the list of words, via functions outside of Word, in order to obtain an unknown word.
One of the ...
Score of -4
0 answers
142 views
Unable to chose a date from a “Date Picker” in selenium python [closed]
In a web scrapping process with selenium Python, I am attempting to select a specific date from a “Date Picker” which includes year and month and day..(see the attached picture named “. But it dose ...
Score of -6
2 answers
224 views
Item index in a for loop [closed]
I am using item variable to access index of a dataframe row with certain cell value but is seems item variable is string, my dataframe address column is a string too. I need to access index of certain ...
Score of -8
2 answers
247 views
How can I improve the efficiency of my code for CSES Missing Number? [closed]
I am trying solve this problem on CSES and am getting a Time Limit Exceeded verdict. May I know how I could make this program faster and more efficient?
https://cses.fi/problemset/task/1083/
n=int(...
Score of 2
1 answer
179 views
Threading Flask and 'while' loop
I want make the while loop and Flask program run simultaneously:
import serial
import sqlite3
from flask import Flask
from pynput.keyboard import Key, Listener
import threading
sql_conn = sqlite3....