Questions tagged [python-3.x]

Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 3 interpreter only. Do not mix this tag with the python-2.x tag.

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

Handling exceptions

I had a blast to get a awesome code reviewer yesterday who taught me very much and I do hope I have done a pretty good job on improving my knowledge both with exceptions and in general. Currently I ...
3
votes
0answers
22 views

PyQt5 developing complex Window GUI and making everything its own class

TLDR: Is my code following best practices for OOP and PyQt5 regarding inheritance, and is it okay to initialise classes within another class? What can I do to improve my methods, or what would be a ...
-2
votes
0answers
31 views

How can i optimize this python code [closed]

...
1
vote
0answers
21 views

Linear conflicts heuristic for 15 puzzle game

I'm trying to solve the 15 Puzzle problem using IDA* algorithm with a Linear Conflicts heuristic. I already implemented the heuristic from what I understood : link Here's my goal state ("snail&...
2
votes
1answer
129 views

Check if new dict values has been added

I have been working on creating a scraper that auto detects if there is any changes on a website as example as there is a release date or a increas/decrease of size value. I have created couple of ...
0
votes
3answers
66 views

Fibonacci generator python implementation

I wrote this code for a fibonacci sequence generator. Can anyone tell me whether my code is designed well? if not, why? ...
3
votes
3answers
92 views

SUVAT Calculator web app using python streamlit

I have made a calculator app to help Bengali high-school students in solving mathematical problems on Newtonian equations of linear motion aka SUVAT equations. I am using python version 3.8.8 and ...
1
vote
2answers
77 views

Get data from JSON values

I have been working on where I want to improve my knowledge to do a safe JSON scraping. By that is that I could pretty much do a ugly workaround and wrap it into a try-except but that is not the case. ...
2
votes
2answers
67 views

Cython Fibonacci Sequence

For my current job, I've been told that soon I'm going to be porting our Python code to Cython, with the intent of performance upgrades. In preparation of that, I've been learning as much about Cython ...
2
votes
1answer
44 views

Singleton handler for reading and writing configuration.json

In a current project of I have multiple modules that need to read from and write to a config.json file, where the settings are saved as nested dictionaries. I chose ...
2
votes
1answer
65 views

Stack Exchange Marathon Bot – Part 1: Bot structure

This code review is for my Stack Exchange Marathon Bot project, a Telegram bot for playing a dumb little game involving the Stack Exchange network. Since the codebase is not that small, in this post I ...
2
votes
1answer
62 views

Python factory class with dynamic imports

I'm trying to write a factory class that essentially provides a user-friendly frontend to creating objects of different kinds depending on keywords. So the user will just have to import this module, ...
2
votes
2answers
101 views

Scrape webelements

I have been working with requests where I as easy as it is. Scraping the webpage and add it into a dict and print the payload if we find a new value or not. ...
1
vote
1answer
28 views

Run python File With get request flask API

Code is Working Review and Recommend What Are Best Practice What I am trying to achieve. API with Flask that runs any python file from the current directory. Run the file and get output in JSON ...
1
vote
1answer
34 views

Multiple functions connected to SQL

I have created a thread before regarding the similar code review I had before Previous code review - I have updated a small piece of advice I got from previous answer and I did realized I have ...
3
votes
1answer
32 views

Frame Pacing and Animation in Python/tkinter

The goal of each frame of the animation to be the same length as the one before it, regardless of the amount of processing that takes place as the frame is being built. This is a little animation demo ...
9
votes
2answers
713 views

Return quarters of current year

I build this simple function, trying to use PEP 8 Style, something that I discovered recently thanks to this previous question. The function works, but I was wondering if there is a better way to do ...
4
votes
1answer
83 views

Python: Matrix Manipulation module

I made a module called "matrix-py" in python to add, subtract, multiply, transpose matrices I want to know how to improve the code quality and if there's something wrong about my code here's ...
2
votes
1answer
63 views

Mutilple functions connected to database

Today I have learned alot and still learning. I have came to a situation where I have realized that I have created a database with multiple functions that does similar stuff but different queries. ...
4
votes
3answers
152 views

In memory “table” filtering in Python

I'm working on a mini-framework in Python, designed largely for backend REST APIs. One important aspect I'm working on now is testing, and I'm designing a drop-in backend replacement that switches it ...
0
votes
0answers
23 views

Return screenshot data from subprocess without residual files

I have a use case, where I want to take screenshots via scrot without leaving behind residual files: ...
5
votes
1answer
56 views

Async download of files

The following code is an async beginner exploration into asynchronous file downloads, to try and improve the download time of files from a specific website. Tasks: The tasks are as follows: Visit ...
1
vote
0answers
9 views

A thread-safe WebDriver pool to submit browsing jobs to

For a project, I need to make use of Selenium WebDrivers, and since they're so expensive to start, I decided to write a pool to manage them. ...
3
votes
2answers
137 views

Timer convenience class to time code execution for user output

I implemented a convenience class to time code execution and print it to the user. This is part of a bigger project that will be distributed to external users. The timer however is only called by ...
7
votes
3answers
1k views

Python discord bot

So in my free time, I made a discord bot to play around with and learn a bit of python. I'm mainly a java developer. The bot has a few commands that allow it to find and output recipe for cocktails ...
1
vote
1answer
75 views

Bank database program

I have been trying to improve my Python coding and was just wondering if there was a more pythonic way to perform what I have done so far, namely around the date in the ...
2
votes
1answer
19 views

Reducing running time of creating integration field in flow field algorithm (python)

The integration field needs to get recalculated every time the starting or goal coordinates change. I wanted to use the flow field algorithm for a problem that includes bigger mazes with changing ...
1
vote
0answers
31 views

Open and update csv file

...
6
votes
2answers
151 views

Flatten JSON to string

The code below is a Python module to flatten JSON-like structure (nested dictionaries and lists) to a single string. It also provides partial result in the form of flat list of strings. This ...
8
votes
3answers
419 views

Print receipt from cash register in Python

Problem Output a receipt of purchased items. Inputs: products_text_path: Products are found in a text file in <barcode>:<name>:<price> line ...
3
votes
2answers
76 views

Function for checking if a string is a path or an URL be improved

I made myself a function to check if a string is a path or an URL: ...
5
votes
3answers
123 views

Optimizing an implementation of the RKF method

This is an algorithm regarding the RKF method: ...
3
votes
2answers
93 views

Parsing a text file into a pandas DataFrame

I have a .txt file that looks like this: ...
0
votes
0answers
11 views

Filter string depending on filtered & unfiltered keywords

I have worked on a small script where I check if the given string is a filtered or unfiltered keyword. Basically if its filtered then we want to add a additional key to dict. with value True, if its ...
1
vote
0answers
38 views

validation and test loss for a variety of PyTorch time series forecasting models

Hi everyone I'm trying to reduce the complexity of some of my Python code. The function below aims to compute the validation and test loss for a variety of PyTorch time series forecasting models. I ...
0
votes
0answers
14 views

Markov Chain Monte Carlo (MCMC) wind simulate

I want to generate wind data with the use of MCMC. The results I am getting are quite off from the measured mean values not sure why. SIMULATE WIND DATA ...
3
votes
0answers
48 views

Toy neural network give poor results

I'm a beginner both in Python and Tensorflow. I made a toy neural network to learn both. The objective of the NN is to identify the module c, or separation between lines defined by random points, and ...
1
vote
0answers
16 views

Nintendo Switch emulator log analysis Discord bot

This is my first attempt at open source contribution via a Python discord bot, built to analyse user-uploaded log files and give quick, at-a-glance information for support staff. The PR is here: https:...
0
votes
1answer
64 views

for loop in one line (for python -c)

I want to use python -c to remove wheel files from the dist/ directory in my project. (*) Actually, I use the following command: ...
3
votes
1answer
37 views

My 'almostIncreasingSequence(sequence)' code is too slow for lists that have 10000+ elements. [CodeSignal]

I asked this question on Stackoverflow as well, but I think it's best suited here because my code needs optimization instead of error checking (that I previously thought). I've made changes to my code ...
1
vote
0answers
43 views

Python shape detector code

I am writing an object oriented shape detector, first time in Python. I come from a Java background. Can you provide any coding advice? https://www.pyimagesearch.com/2016/02/08/opencv-shape-detection/ ...
4
votes
2answers
48 views

Radix Sort Speed

I have implemented a radix sort algorithm in Python 3. It first finds the maximum number of digits in the list, then changes them to strings and adds 0's. For example, [7, 23, 107, 1, 53] to ['007', '...
0
votes
0answers
24 views

Three Sum Algorithm

I made a randomized algorithm to solve the three sum problem. There are two key parameters: number of solutions, and total. Notably, the algorithm might generate a duplicate solution. This is not ...
5
votes
1answer
103 views

Quicksort Algorithm Speed

I have made a sorting algorithm in Python 3. This sorting algorithm is a modified optimized median of 3 quicksort, with network sorting for lists of size up to 16 and for finding the median. I have ...
20
votes
6answers
3k views

Password validator

I have made a password verification "program" which takes user input and checks whether the password is valid or not. Based on that, a reply is printed. ...
6
votes
2answers
148 views

Asking for a yes/no user input

So I have encountered a problem with asking user for input to be exact what is the best way to ask yes/no, for example accepting y / n and why is ...
2
votes
1answer
56 views

Recursive type checking for containers

This code checks the type, length and depth (highest number of nested containers) of the container as well as the type of its sub-containers and its elements. There are also two simple methods for ...
3
votes
3answers
71 views

Printing dynamic ascii-art shapes based on user input

In the following code I used a while True: loop and implemented break, because I couldn't figure out a cleaner solution than an ...
3
votes
1answer
40 views

Generating multiple new arrays using numpy

Say I have the following two different states: state1 = [0, 1, 0, 1, 1] state2 = [1, 1, 0, 0, 1] And I want to generate n number of new states by only changing the ...
0
votes
1answer
43 views

Using asyncio and aiohttp in classes

To better familiarize with async requests I wrote a very simple scraper that relies on aiohttp to retrieve some basic information from the product page (product ...

1
2 3 4 5
92