All Questions

Tagged with
Filter by
Sorted by
Tagged with
0votes
0answers
9views

How to write UnitTest for a websocket notification class in python?

I am not sure how i can mock the websocket.serve method and other methods of websocket module, Need help in creating a unittest for this class. if anyone help in creating unittest for these methods? ...
user avatar
-1votes
0answers
13views

Python's Bluetooth library of the Bleak report "bleak.exc.BleakError: Could not get GATT services: Unreachable" , how to solve it?

I'm a rookie, I've been doing nothing for a few days and have to turn to overflow for help (┬┬﹏┬┬) Windows 10 downloads a python third-party library of the bleak package and conda's virtual ...
user avatar
-3votes
0answers
18views

How do i start another python script(pygame) and when the game window is open go back to the program but the game should still work

This code starts my game inside of my voice assistant: elif Answer1.lower() == 'game5': import snake snake How do I start the game window, let the game work but go ...
user avatar
0votes
3answers
33views

How would you convert the following dictionary to a specific JSON structure?

I'm by far not a Python3 hero, but focussed on learning some new skills with it, thus any help would be appreciated. Working on a personal project that I want to throw on GitHub later on, I run into ...
user avatar
-6votes
0answers
21views

Difference between spectral and pseudo-spectral method while writing python code [closed]

What are the differences between spectral and pseudo-spectral (method) in Python code? Kindly, show good examples of codes where I can understand the basic differences between the above two methods.
user avatar
  • 1
0votes
0answers
21views

TypeError: 'dict' object is not callable in BeautifulSoup [closed]

I tried writing code that would get all the titles and links on Google search result, then print all those titles and links. from bs4 import BeautifulSoup import requests import colorama from colorama ...
user avatar
0votes
0answers
27views

how to convert nested dictionary into table using python for loop?

I have a nested dictionary which look like this: m = {'match':{'football':{'cricket':'batball','player':'joe','match':36}}} and I want to convert this dictionary into table using for loop without ...
user avatar
  • 23
0votes
0answers
10views

Ragged Nested Numpy Array to Tensor

I have ragged nested arrays of .npy file that I have processed. The error is that it my model failed to convert the NumPy array to a Tensor with the remark 'Unsupported object type list') I have try ...
user avatar
-2votes
1answer
20views

Python newb "Fill in the empty function so that it returns the sum of all the divisors of a number, without including it."

Good Day I'm a Python newb and I'm having a hard time figuring out how'd the output ended up 55? Also what is this sum in return sum? Are there any other methods also to make it less complicated? def ...
user avatar
  • 1
0votes
0answers
7views

How to crate a Hybrid Work Model roster simulation

My office is currently manually creating Hybrid work model Rosters. Can we automate the process in Python/Pandas? Rules for creating a roster is: for 2 weeks (10 working days) people should be in ...
user avatar
-1votes
0answers
12views

Please help: My PyInstaller exe is not opening

I have this program which I can use to update a program. The problem is when I convert the program to .exe from .py using pyinstaller(using --onefile and --noconsole commands too) it is not opening. ...
user avatar
  • 1
-1votes
0answers
17views

Difference in precision when using Decimal constructor [duplicate]

I am learning Python and read about Decimal. Then i noticed the difference in output of the following two statements: >>> Decimal('0.1') + Decimal('0.10') + Decimal('0.10') - Decimal('0.30') ...
user avatar
  • 128
0votes
1answer
41views

Pandas get rows with subtracting rows as a index

I have a function in python that gets the two rows for a yfinance dataframe of tickers. I am doing a calculation, where I make a row that holds the value obtained from subtracting the value, then ...
user avatar
  • 415
0votes
0answers
15views

Getting RuntimeError in Python while submitting in UVa Online Judge

I tried to solve problem 101 on Online Judge but Online Judge is giving me a RuntimeError. However, it runs just fine on my computer. This is my code: total_blocks = int(input()) inp = '' commands = []...
user avatar
0votes
0answers
34views

Calculating complexity of custom list append function

I have created "C Array" in Python and added implementation for append as below: class Array: def __init__(self, size): array_data_type = ctypes.py_object * size ...
user avatar
  • 11.2k
0votes
2answers
36views

Return a new instance from a class method

I've implemented a date class, which calculates the next day's date and the previous day's date. eg. if today is 3/26/2022 (MM/DD/YYYY) then my method nextday gives 3/27/2022. However, instead of ...
user avatar
0votes
0answers
12views

Jupyter Notebook Organization w/ Reusable Code

I'm using: Python3.7 VS Code + Jupyter Notebook Extension Both macOS & Windows, and I keep my files in a Dropbox folder I want to organize my notebooks into directories so it's easier to ...
user avatar
  • 724
-1votes
0answers
14views

How to broadcast a message to all listening devices with Python

I'm trying to make a program that includes a "find available devices" feature, sort of like Chromecast. What I need to know is, how can I use Python sockets to send data to every device on ...
user avatar
0votes
0answers
13views

How do I change the angle of a rectangle on the tkinter Canvas?

I am trying to draw a cartoon frog on Canvas, on Python 3. This is my code for the leg: RightLeg = c.create_rectangle(600, 600, 700, 400, outline= 'green', fill= 'green') I get my frog body off ...
user avatar
0votes
2answers
12views

How to write a python program to interact with the browser?

In my company intranet, any request to an external website X in Internet will be redirected to an internal page containing a button that I have to click on. Then the external website X in Internet ...
user avatar
0votes
1answer
26views

How to skip the space in the txt file

I'm trying to count all the letters from a text but I want to exclude the counting of a letter next to a space from collections import Counter text = 'in the seas and let fowl multiply in the earth \...
user avatar
  • 1
0votes
0answers
14views

Re-Export function/class from another package

I have a few package's on my team. Some are smaller and used in other, larger packages. What is the best practice for importing a function/class from one package and then re-exporting it in another ...
user avatar
0votes
1answer
12views

Pysimplegui everything transparent except 1 element

How to make only one Text element not transparent? As transparent app I use sg.Window option alpha_channel=0.1, but one text element I need to make better visible. It is possible with Pysimplegui? ...
user avatar
  • 670
-3votes
0answers
16views

Python Get Average of Multiple Nested Dictionaries [closed]

I have a list of dictionaries. Each dictionary by itself can have nested levels, but the keys will always be the same. I'm trying to find the best way to get the mean of these values. Example List of ...
user avatar
  • 73
1vote
3answers
37views

Formatting Multiple Columns by Name using .loc

My goal is to state a list of columns by name that I want to apply the formatting to. The section that is commented out is ideally what I am after (which would mean removing the line of code directly ...
user avatar
0votes
0answers
24views

Remove stopwords using multiprocessing python

Removing stopwords is a standard NLP task. If we have N texts, how can I use multi processing in Python to, given a common list stopwords remove stopwords in parallel from the N texts? Normally one ...
user avatar
0votes
1answer
39views

Add item to existing list and be able to print list for each item in range in new line

Hi am new just started Computer Science at London Met we have programming in Python. In this code am trying to add items to already existing appended list list.append([student_name, student_age, ...
user avatar
-1votes
0answers
13views

PyAutoGUI Error "TypeError: 'NoneType' object is not iterable" [duplicate]

I am making a "super simple" script in VS Code that should use PyAutoGUI to find this button: . The problem is when I try to run this code: #import libraries import pyautogui as pg #sleep ...
user avatar
0votes
0answers
11views

how can I customize error response from aws authorizer function?

I have written a lambda authorizer function that calls two custom authorization services to validate the input token. So, from lambda authorizer, I want to return different possible messages for the ...
user avatar
  • 83
-1votes
0answers
14views

Why is my collision with Pygame not working properly? [duplicate]

So I'm making a little archery game for school. To check collision between the arrow and the targets I use the pygame.sprite.spritecollide() function, and the sprites are masked. This is the arrow's ...
user avatar
1vote
2answers
32views

Selenium Select to return a list?

In python we have: select = Select(driver.find_element_by_id('fruits01')) But what if I want to have a list of all select tags and not just the first one? I tried: select = Select(driver....
user avatar
  • 23
-2votes
0answers
19views

How do I make it so that when I type something it responds with something in specific (python) [closed]

Im not looking for something like username = raw_input("Enter username:") print("Username is: " + username) But something so that the output is: User:hi Output:hey there User:wow ...
user avatar
0votes
3answers
43views

functools.reduce in Python not working as expected

I would like to sum across keys of dictionaries nested within a list using the functools.reduce function I can accomplish this WITHOUT the functools.reduce function with the following simple program: ...
user avatar
0votes
1answer
18views

checking if message author has a certain role

I am making an automatic banning system with a discord bot. So once a message with a steam id is placed into the channel, it will run through an API and ban them (I've got this working) what I am ...
user avatar
0votes
1answer
24views

Unable to compare the time field in dictionary to current time

I am learning python. I am trying to compare the date in Time field of a dictionary with the date in current_time and if it matches, i am trying to print the key , id in JIRA_ISSUE but however, ...
user avatar
  • 5
1vote
1answer
33views

Python Selenium How to Select from Dropdown?

I was testing my code over: https://semantic-ui.com/modules/dropdown.html I wrote the following code in Python3 which finds all drop-downs in a given webpage and selects the last option for each drop-...
user avatar
  • 23
-4votes
0answers
13views

OSError: [Errno 22] Invalid argument: '01:11:37.png' [closed]

[enter image description here][1] [1]: https://i.stack.imgur.com/2pCwf.png llll
user avatar
0votes
0answers
16views

Function printing my 'else' without fulfilling the condition [duplicate]

im having trouble with the function bellow where i need to check if the 'key' input is already in the function parameter. only if the 'key' is already in the parameter that is passed my else should be ...
user avatar
-4votes
0answers
29views

How do I delete an object? [closed]

I want to delete an object in Python. class User: # how many users active_users = 0 def __init__(self, username, first, last, age): self.username = username self....
user avatar
0votes
0answers
30views

Read tabular file with multiple headers and values

I have to read/stream a file which has multiple rows in between with headers: It has one file header and corresponding to this only one row as file record. And then it will have one/more batch ...
user avatar
  • 5,188
-2votes
0answers
23views

python import csv starting on line x and only import y columns (not using pandas)

I am looking to import a .csv file using import csv. I don’t want to use pandas. I would like to start reading the file on line 10 then don’t want the first column but start on the second column of ...
user avatar
1vote
2answers
35views

Split string in Python while keeping the line break inside the generated list

As simple as it sounds, can't think of a straightforward way of doing the below in Python. my_string = "This is a test.\nAlso\tthis" list_i_want = ["This", "is", &...
user avatar
  • 124
0votes
2answers
28views

String search on dataframe using key/value from dict

I am trying to match the string present in the below dataframe's 'Disease' column with the key from the dict and if the string is present then change the value in the 'category' column to the value of ...
user avatar
  • 1,122
-1votes
0answers
25views

python package contain file however it's missing after pip install [duplicate]

I have problem with correctly using setuptools in python. my-app/ - src/ | - main.py - dep.txt In my project I have a dep.txt file which i add while building a python package in MANIFEST.in. include ...
user avatar
  • 166
0votes
0answers
12views

maws2.0.py yield start ^SyntaxError: 'yield' outside function [duplicate]

The program maws.py was developed by students in 2015 at Uni-Heidelberg but I could not contact the developer. I checked maws.py with PyCharm and the many indentation problems were solved, I hope. ...
user avatar
  • 43
-1votes
0answers
37views

Python: no module named even sys.path includes it

I didn't find a solution from other posts: I don't use relative path in my case, I use absolute path sys.path.append(os.path.abspath("../../set/tech")); The path to the desired module is ...
user avatar
  • 2,309
-3votes
2answers
50views

ValueError: not enough values to unpack (expected 3, got 2) (OpenCV) [duplicate]

I have a problem with python program( line 22 -(_cnts_) ). I use win11, PyCharm. I am getting error ValueError: not enough values to unpack (expected 3, got 2). import cv2, time import pandas ...
user avatar
1vote
1answer
37views

How to pass tuple with one element as param in sql query Python?

How can I pass tuple with only one element as param in sql query Python? I have tried this solution suggested here: imploding a list for use in a python MySQLDB IN clause ids = [(UUID('1232a4df-5849-...
user avatar
  • 545
-1votes
1answer
24views

Python variable not registering with if statement [closed]

When I ask the user if they would like to mega size their order, python says that it is a invalid entry. Dont mind the choice[] list, it is used elsewhere. print("What size would you like?\...
user avatar
0votes
1answer
19views

How to use read_excel inside a loop?

when I use read_excel outside a loop it creates a normal dataframe: pd.read_excel('file.xlsx') but I need to parse files in order to create dataframes, like: os.chdir('/path/to/dir') for file in glob....
user avatar

15 30 50 per page
1
2 3 4 5
3699