Skip to main content

All Questions

Tagged with
1 vote
0 answers
50 views

VSCode rename symbol ignores references in other files

I have a class attribute account_values that occurs multiple times in class MyClass, all in the same the file file1.py. It is also referenced multiple times in file2.py. All the references in file1.py ...
Llaves's user avatar
  • 761
0 votes
0 answers
33 views

Refactoring marshmellow schema to pydantic 2

I have been struggling to refactor this marshmellow schema to pydantic 2. Problem is with AttributeValue field. When I refactor this to pydantic, I always get strange errors regarding this field. This ...
Sharmiko's user avatar
  • 623
0 votes
1 answer
92 views

How can I highlight or select all Pandas code in Visual Studio Code

I want to transition from Pandas to Polars in a big Python project. Is there a way to highlight or find all Pandas commands I've written in Visual Studio Code (or another IDE if necessary) so I would ...
gernophil's user avatar
  • 609
0 votes
0 answers
55 views

Evaluating the quality of my code DearPyGui

I have a small project for dearpygui, is it possible to soberly assess the quality of the code and the approach to the project. Here is my project on GitHub. I'm a beginner in python and I want to ...
Kolhun's user avatar
  • 1
0 votes
0 answers
70 views

Resolving ImportError and AttributeError in Python 3.10 for Metrics Collection Scripts

I am currently upgrading our system to Python 3.10 and have encountered issues with our metrics collection scripts, specifically with standard library imports and attributes that have become ...
user3369545's user avatar
2 votes
1 answer
113 views

How to bulk remove trivial if statements

I'm working on refactoring a big codebase and part of the refactor includes removing some checks. I couldn't figure out a way to do this efficiently. For example if the old code was something like: ...
Lucas Daher's user avatar
1 vote
1 answer
81 views

Pythonic refactor advice needed

I am writing a tokenizer for files that have ignored preamble. The files are written in Markdown and there is a list of keywords in H1 titles that change the state of the parser. When an EOF is ...
pawkw's user avatar
  • 59
0 votes
1 answer
110 views

How to Remove Wildcard Imports from a Large Python Repository?

I am working on a large python project that contains many thousands of files, includes a mix of independent scripts (many with main functions) and common modules. Unfortunately, in my project there is ...
Kfir Ettinger's user avatar
-1 votes
1 answer
97 views

I want to add retry logic and. refactor the code in the python socket connect code

I have the below Python code which checks whether the ssh host is up or not: `for hostname ,ipaddr in host_dict.items(): if tcp_conn.tcp_port_is_open(ipaddr, constants.TCP_PORT, ...
Saurav K's user avatar
3 votes
3 answers
108 views

How to refactor similar functions in Python?

I have defined multiple functions where I search for a specific pydantic model in a list of pydantic models based on some attribute value. SocketIOUserSessionID = str RoomWithIndex = tuple[Room, ...
Slava Pasedko's user avatar
0 votes
1 answer
134 views

Improving LSTM Model for Stock Trading and Speeding Up Code Execution

I have been working on a stock trading algorithm using an LSTM model. The algorithm fetches real-time data, makes predictions, and decides whether to buy or sell stocks based on the predicted price. ...
Sym Sym's user avatar
0 votes
0 answers
29 views

Refactoring Python Code for Mouse and Keyboard Actions with Pynput

I have a script that uses the pynput library to perform a series of mouse and keyboard actions. The script highlights certain areas on the screen, copies the highlighted content, and saves it to ...
鈴木悠真's user avatar
-4 votes
3 answers
65 views

Python: Is there a way to remove a character without regard to capitalization? [duplicate]

My code is supposed to remove vowels from the user inputted string. It works correctly, but I'm trying to see if there is a way to simplify my code. A screenshot of my code I originally didn't have ...
corrie_in_the_house's user avatar
1 vote
1 answer
136 views

Defining the value of one variable in a constraint in relation to another variable without making the problem nonlinear in Pyomo

Background references: [1] Generating constraints with conditional summing over several pyomo subsets [2] Debugging why some requests are unexpectedly not satisfied in pyomo I am getting a correct ...
user23390596's user avatar
0 votes
1 answer
56 views

can't we vectorize code with nested loops to update matrix values

I wrote a piece of code but I am not sure if we can get rid of the loops and vectorize it to make it faster. Can you please give suggestions? I am just updating the co-occurence matrix . M = np.zeros(...
vkaul11's user avatar
  • 4,224

15 30 50 per page
1
2 3 4 5
32