Category "python"

Branching out a function

I've built a function that tries to extract some information from a string. Before: function (string) Now, I want to refactor that function by receiving two ext

mypy fails for numpy sum

This code snippet works: py -c "import numpy; print(numpy.array([[1,2,3],[4,5,6]]).sum(axis=0) % 2)" [1 1 1] But mypy gives an error: py -m mypy -c "import num

How to ensure that the labels of two axes do not overlap?

I have some questions about labels of axs. Firstly,I have 2 subplots which can be seen below. As you can see, labels of first ax are overlapping with the second

Is it possible to have input from one device populate one field in tkinter, and another device that populates a different field?

I have a keyboard and a USB bar scanner and two separate monitors at different locations all connected to the same computer. I want the keyboard to enter data o

Optimization and objective function using Scipy

I am trying to optimize an objective function using scipy. I simplified what I would like to do to focus on the problem more. There is an array called operating

How to access a QPushButton object inside a QWidget?

For example in the code below: >>> from PyQt5.QtWidgets import * >>> import sys >>> app = QApplication(sys.argv) >>> widget

How to convert a numpy array with dtype=object to a numpy array of int?

Now I have a numpy array: In [1]: import numpy as np In [2]: a = np.ones(10) * (1 << 64) In [3]: a Out[3]: array([1.8446744073709552e+19, 1.84467440737

Kivy passcode login

I'm trying to make a password system with kivy, and tried coding how many tries the users have until the code does somthing but every time i input a text it goe

How do you get VS Code to write Debug stdout to the Debug Console?

I am trying to debug my Python Pytest tests in VS Code, using the Testing Activity on the left bar. I am able to run my tests as expected, with some passing and

Python Pandas how to get f-string to work in an url

I am getting an error of urllib.error.HTTPError: HTTP Error 404: Not Found. I feel like f-string should work for the url but it is not how would I fix this? imp

Unable to start an application using pywin32 package - invalid class string error

I have installed Python 3.10 and installed the pywin32 package. I tried to open an application using Python, however I am facing an error: "invalid class string

How to synchronize a windows folder in python flask app with a sqlite database table?

I am looking for a solution to compare filenames inside sqlite database with filenames in a windows directory (app.config['UPLOAD_FOLDER']). I have a sqlite da

matplotlib multiple line plot color according to reference value

If i have a dataset: import numpy as np import matplotlib.pyplot as plt y = np.array([np.random.randn(10) for k in range(100)]) plt.plot(y) And a correspondin

Pycaret classification.compare_models does not display results grid

From the documentation and tutorials for pycaret, I expect the classification.compare_models() function to return a grid such as... Model Accuracy AUC Recall

download specific image from the list

my manager asked me to create script to download images for our client. These are images for goods on a market place. Every image exist on a separate page about

python automatically change a variable from list to string inside a for loop

Python automatically changes a variable from list to str inside a for loop so I got an error when I append to the list. Why does this happen?

Completing the sudoku terminal game

Given below is a program to make and solve ( by the user ) a sudoku puzzle . import random from tabulate import tabulate base = 3 side = base**2 level = 1 de

how do you make a transparent overlay for a specific window that doesn't block interactions beneath said overlay in pyqt5

Im trying to make a simple helper overlay that display info over a window but doesn't interfere with interactions on said window(click through overlay). I prefe

Remove list in lists that satisfied the condition

I'm trying to make a quick OCR for specific use, I know should've just write a preprocessor for normal OCR and that would been faster but this idea came up to m

How can i get raspberry pi pico to communicate with PC / external devices

For example when i give 5 to the code, i want to turn on the led in our rpi pico (rpi pico connected to pc with cable) #This code will run in my computer (test.