Questions tagged [python-3.x]

USE ONLY IF YOUR QUESTION IS VERSION-SPECIFIC. For questions about Python programming that are specific to version 3+ of the language. Use the more generic [python] tag on all Python questions. Use the [python-2.x] tags for Python 2 questions.

Filter by
Sorted by
Tagged with
0votes
3answers
35views

I have a nested while loop and the father while loop will keep looping rather than ending with break

I made a nested while code and option 1 is the only one that works. It will break both while loops while options 2 and 3 only break their loops? I've tried copy-pasting the code for option 1 for the ...
user avatar
  • 3
0votes
0answers
28views

How to append dictionaries to a list in Python?

I have create a dictionary named item_dict. After iterating the rows of a data frame, where multiple rows have the same id value, I want to append to item_dict a list ,and to that list to add more ...
user avatar
  • 2,320
0votes
0answers
16views

Upload file in chunks with progress bar of the global upload status rathen than of every single chunk

I have a small script which reads data inside a file in chunks, encodes them and then runs curl to send a POST request for every chunk. I would like to add a progress bar of the global upload status ...
user avatar
  • 15
0votes
0answers
13views

How to print score of stone, paper and scissiors in python

currently I am making a simple game of stone, paper and scissors where u take input from user and see through random module the input of computer. The user gets 10 chances and whoever has the most ...
user avatar
0votes
1answer
6views

Why howdoi module is not working on Pydroid3

Im using Pydroid3 as editor and compiler. I want to get my doubts clear on the app itself. I have installed howdoi module on the terminal. But when asking a question it shows syntax error. I tried ...
user avatar
-1votes
0answers
12views

What happens when a module is imported twice in different packages?

I have a project and I want to split classes into different files to be more readable Also, it should make me easier to debug I have two packages called A.py & B.py I need one module in both two ...
user avatar
0votes
1answer
28views

pandas aggregate column doesnt exist?

Currently i have a dataframe that i am preforming a group by on with aggregate functions. these are the functions aggregation_functions = { '12_months': 'sum', '...
user avatar
0votes
0answers
15views

Selecting data with boolean

I have this data: Time Filename 60Ni 61Ni 62Ni 63Cu 64Ni 65Cu 66Zn 0 input/25.03.2022/220310001_Blk.TXT 0.004213561117649 0.0004941140553758 0.0008264054505464 0....
user avatar
  • 25
0votes
2answers
36views

In PYTHON, How can i append listA[]s each index values to the ListB[]s each indexs values. Note both lists have same size/length

I am new to Python. Please help me. Example : I have 2 different lists indexnameList and payloadList. Each contains 2 values. length/size= 2. Given below. indexnameList = ['c_aa98efb4-630a-4eef-b51e-...
user avatar
  • 1
0votes
0answers
16views

PytorchStreamReader failed reading zip archive: failed finding central directory

I am trying to learn pytorch from a book, but it seems not a straight line for me. I coped the code below and pasted in my jupyter notebook for running but it gave me an error I am not able to ...
user avatar
  • 57
-2votes
0answers
20views

sqlite3.OperationalError: unable to open database file for directory attack

(kali㉿kali)-[~/Music/Instagram] └─$ python3 instagram.py lory.nar09 password.txt usage: instagram.py [-h] [-u USERNAME] [-p PASSLIST] [-px PROXYLIST] [--prune PRUNE] [--stats] [-nc]...
user avatar
0votes
2answers
22views

Python lxml xpath is selecting more content than expected

I'm tring to save the result of searching. A typical result is something like: https://www.genecards.org/Search/Keyword?queryString=NONHSAT072848.2 In the html file, the information I need is within ...
user avatar
  • 37
0votes
1answer
10views

Creating a custom User model by extending AbstractBaseUser

I am trying to create a custom User(CustomUser) by extending AbstractBaseUser. I am trying to remove username field and use email for authentication.I have not done the first migration yet. Here is ...
user avatar
-2votes
1answer
38views

TypeError: 'int' object is not callable in python3 [duplicate]

# Make a ship ship = Ship(screen) #Set the background color. bg_color = (230, 230,230) #Start the main loop for the game while True: #Watch for keyboard and mouse events for event in ...
user avatar
  • 1
0votes
1answer
18views

When a user input a letter it displays the hidden word and some of the loops

Write a program to play the following game. There is a list of several country names and the program randomly picks one. The player then has to guess letters in the word one at a time. Before each ...
user avatar
-2votes
0answers
25views

how to add new sheet in excel using python without any library?

I am opening excel file using with open method. I have to add new excel sheet without using any python library or module.
user avatar
  • 23
-1votes
1answer
25views

error while using Self signed ssl certificate for Mqtt broker

I was using mosquito broker with user name and password authentication. Broker URL is made public so that it can be accessed by a Django web site and raspberry pi now am trying to implement ssl ...
user avatar
  • 21
-2votes
0answers
8views

Get all visited links show them using Qwebengineview pyside2 /pyqt5

I searched a lot but can not find about it. What I want I want to get all history of visited link and show them by using a button in pyside2/pyqt5. (like when we clicked on history button in chrome ...
user avatar
0votes
1answer
21views

bs4 `next_sibling` VS `find_next_sibling`

I struggling with usage of next_sibling (and similarly with next_element). If used as attributes I don't get anything back but if used as find_next_sibling (or find_next) then it works. From the doc: ...
user avatar
  • 1,561
0votes
2answers
47views

How to split list in chunks in equally in python?

i am trying to add users to my group using pyrogram i have 200 user ids in a list - python list_of_users = [user_id1, user_id2, user_id3, user_id4, ...] i also, have a list of 7 clients, what i waana ...
user avatar
0votes
0answers
12views

Django REST Framework: How do I clear the ListCreateAPIView POST form after a POST?

How do I make it so that this form is cleared after a POST request is sent? Right now, clicking POST refreshes the page and updates the table data but the form data remains. The code I'm using is from ...
user avatar
  • 105
-1votes
0answers
13views

How numpy limits the number of CPU cores

My CPU is multi-core. I want numpy to execute on a single core or with a single thread. What should I do? The configuration is as follows. numpy.show_config() blas_mkl_info: NOT AVAILABLE blis_info: ...
user avatar
  • 1
0votes
0answers
18views

Type hinting dictionary that maps strings to python classes

I have a dictionary that maps strings to classes. example of classes: class A: @staticmethod def print_a(): print("Hello A!") class B: @staticmethod def print_b(...
user avatar
-1votes
0answers
30views

Python: type hinting any method of a class [closed]

I'm trying to type hint any method of a class, type hinting __getattr__ is the closest example of what I'm trying to achieve: class A: def hello(): pass class B: def __getattr__(self, ...
user avatar
  • 97
0votes
2answers
19views

File not found error on creating a new file and writing in it

I am trying to create a new file and write on it . but when I am doing something like this I am getting file not found error. seems I am missing something which I can't figure out . data = { "...
user avatar
-1votes
2answers
35views

How to solve "unexpected indent" and "traceback" errors?

I'm trying to code a bot for Discord and can't get my "help" command to work. This is the code I started with: @client.command(pass_context=True,name="help") async def help(ctx): ...
user avatar
0votes
1answer
17views

Estimate the error variance from statsmodels

Python module statsmodels has some methods for Generalised linear model (GLM) as described in https://www.statsmodels.org/stable/glm.html I am wondering if there any method available to obtain the ...
user avatar
  • 2,247
0votes
1answer
37views

Python program ends even if the condition are not met

The condition is that the program will end: -if the balance is less than or equal to zero. -if the balance is greather than or equal to 200. But the problem is that it ends after I input 1 or 2 (1 for ...
user avatar
0votes
2answers
27views

Extract attachments from email and email them as attachments using win32com.client in Python

I am trying to loop through email messages in Outlook using python and get all the attachments in each email, extract them and send them to a different person if it meets a certain criteria. Currently ...
user avatar
0votes
1answer
20views

How to import classes and function from files within the same dir as main.py in Python 3.9?

I am struggling with importing local source files that reside in the same directory as main.py in Python 3.9. I had it working before but couldn't tell why it was working. After a while it stopped ...
user avatar
  • 407
0votes
0answers
7views

How to combine and handle data list in dictionary python

I have a big problem. This is my data.The data structure looks like this. It include metric_name, date_time and data of date_time in metric_name. { "metric_name 1":{ "date_time 1&...
user avatar
  • 15
0votes
0answers
6views

set attribute to a class variable in dataclasses with __post_init__

I have a class like @dataclass_json(letter_case=LetterCase.CAMEL) @dataclass class GraphProcessor: entities: ClassVar[DataFrame] = field(init=False) relations: ClassVar[DataFrame] = field(...
user avatar
  • 454
0votes
2answers
42views

How to remove last character of a string

I have many lines similar to "HHH |**** XYzz| *ABC*hgg|G~GG|G|HJJ|JJJ| |" "HHH |**** XYzz| *ABC*hgg|G~GG|G|HJJ|HHH|" "HHH |**** XYzz| *ABC*hgg|G~GG|G|HJJ|III| ...
user avatar
0votes
0answers
9views

How to filter and then order the rest datas in SQLAlchemy?

I search some information, but they all just teach me filter or order datas. However, I want to know how to order the rest datas after filtered. I try this, but it will say the list have no order_by. (...
user avatar
  • 1
0votes
2answers
50views

How to dynamically populate a nested dictionary from another dictionary

I have a function that should convert its input dictionaries into their correct format. Keys of each input dictionary contains one or more -> to indicate nested structure. dict1 = { 'p1->a-&...
user avatar
  • 328
0votes
0answers
6views

Dataframe to Postgresql without SQLAlchemy

I want to write pandas dataframe to postgresql table. But I dont understand that "INSERT INTO %s(%s) VALUES %%s" % (table, cols) syntax. There are 9 columns value in my dataframe (...
user avatar
1vote
1answer
19views

How to display a certain number of links along with information

How to display a certain number of links along with information? First code asks me which page to open and how many items to display. But no matter what I do, my links are displayed correctly, but the ...
user avatar
  • 47
1vote
3answers
59views

How to upload folder from local to GCP bucket using python

I am following this link and getting some error: How to upload folder on Google Cloud Storage using Python API I have saved model in container environment and from there I want to copy to GCP bucket. ...
user avatar
  • 1,048
0votes
0answers
24views

How to extract different user information into same category in a column for visualization?

I have a dataset of one million data. There is a column name 'Message' which contains all of the information about the user e.g. user email address, different category types, account type, aplication ...
user avatar
0votes
1answer
16views

format rounding the pricision part. why

what is the difference between the below code, can explain? print(format(678906.3456789,"10.2f")) 678906.35 print(format(67890611111111111.3456789111111111111111101111111111111111111101,&...
user avatar
0votes
0answers
9views

"A process in the process pool was terminated abruptly" error on concurrent.futures.ProcessPoolExecutor()

I'm trying to multiply matrices using multiprocessing to see how much faster it can run than a regular synchronous process. Here is the function: def multvecs(inp): vec1, vec2, index = inp ...
user avatar
0votes
0answers
11views

is there a method to verify existence of column in another pandas df? [duplicate]

i have a dataframe like : Name; address ; firstname ; lastname ; postal_city ; number Martin Lustig; Paris France; Martin; Fabien ; Paris ; 0 Adrian Dubois; Lille France; Adrian; Dubois; Nantes ; 0 ...
user avatar
0votes
0answers
10views

Can I display the elements of queue by index in Python?

I am trying to display the elements by index(I know I can display all of them but I need to display them like q[0],q[1]) but I could not find a way for that.Is any way for doing this? listt = [] for ...
user avatar
  • 163
1vote
0answers
20views

I want to create a Weibull probability Plot in Angular

This is the chart i am trying to create in Angular. This comes from the reliability package in python. https://github.com/MatthewReid854/reliability/tree/master/reliability I am using Highchart - ...
user avatar
-1votes
0answers
21views

How to run Python Testing?

I am writing code following instruction of Python Crash Course (Eric Matthes) and encountered error in code testing section. I ran the code in Jupyter Notebook. In name_function.py file: def ...
user avatar
0votes
1answer
24views

Index out of range when it should not

Hello guys im learning python and im trying to make a string that concentrates binary numbers together baseed on similarity from a list .. so ['1','0','0','0','0','1','1'] becomes '1 0000 11' .. I ...
user avatar
  • 25
0votes
0answers
14views

subclass for NameError: name 'side_length' is not defined

class Polygon(): def __init__(self, side_lengths): self.side_lengths = side_lengths def perimeter(self): return sum(self.side_lengths) def __str__(self): side_lengths = len(self....
user avatar
-2votes
1answer
16views

Python array conditions

I wanna know how do I initialize a 2d array where the first row will have all even from 0-10, and 2nd row will have all odd from 11-20, so and so until in column 10 we will have 91-100 of all odd? ...
user avatar
0votes
1answer
34views

Definition of error in polynomial interpolation

I needed to write a program for polynomial interpolation of the Lagrange polynomial (g(x)) for the function exp(x) (f(x)). n = 10 x = [] y = [] def f(x): return math.exp(x) def lagranz(x, y, t): ...
user avatar
0votes
0answers
12views

Django multiple user login on multiple tab session issue

I have an issue with my Django app. If I use to login to the app with different users from different browser tab , then it is loging out the first user. I am using django file bases session, which ...
user avatar
  • 173

15 30 50 per page