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
2
votes
1answer
38 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
40 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 ...
10
votes
2answers
726 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
89 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
85 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
162 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
26 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
67 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
12 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
82 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
33 views

Open and update csv file

...
6
votes
2answers
157 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
470 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
85 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
125 views

Optimizing an implementation of the RKF method

This is an algorithm regarding the RKF method: ...
3
votes
2answers
162 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
43 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
16 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
52 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
18 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
67 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
44 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
49 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
104 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
164 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
60 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
72 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
55 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
vote
1answer
34 views

Read created json files inside a given folder

I have been working with where I use watchdogs to be able read whenever I have created a file by the name -> kill_.json and it contains: ...
2
votes
1answer
63 views

Read created files in a folder

I have been working with where I use watchdogs to be able read whenever I have created a file by the name -> kill_.flag and it contains: ...
2
votes
1answer
86 views

How to optimize my telegram bot written in Python?

I have written a fairly simple bot that provides information or additional choice based on the user's query. It runs well and does the job, however, I was wondering how can I optimize my code and use ...
0
votes
2answers
42 views

Machine Learning Program

I've written a program that finds the difference between data and gives output. Here's the code: ...
0
votes
5answers
81 views

Determine whether a magazine contains the words needed for a ransom note

This is a website Question on Hackrrank called Hash Tables: Ransom Note: Given the words in the magazine and the words in the ransom note, print "Yes" if we can replicate the ransom note ...
2
votes
1answer
66 views

Find sub-list index with the closest to a given number sum

The task that I have to perform is to take an array of a specific length, and figure out which sub-list has the closest sum to another given number. Then, I need to print the index of that sub-array. ...
2
votes
1answer
98 views

Sort and reverse lists

I started programming in Python after learning the basics of C, which is why I like the user-defined functions to be described after the main() function's job is over. Also, I like to specify the sep ...
5
votes
3answers
416 views

Caesar Cipher Encryption / Decryption in Python

I'm trying to write a Python program to predict the most likely substitution for a Caesar cipher. I managed to get it working, but it just seems very clunky and slow, especially because I need to ...
0
votes
0answers
31 views

Reimplemented R function(s) is surprisingly slow

I reimplemented the functions https://rdrr.io/cran/fclust/man/RI.F.html, https://rdrr.io/cran/fclust/man/ARI.F.html and https://rdrr.io/cran/fclust/man/JACCARD.F.html of the R package https://rdrr.io/...
0
votes
0answers
13 views

Scikit-learn SVR stock prediction

I am messing around with the sklearn ML library to see if i can "predict" stocks with it, currently when it takes all the datapoints i have, it "predicts" it but i am trying to get ...
0
votes
0answers
20 views

Organization of work with MongoDB in Flask

I`m trying to make an API for Flask together with MongoDB, before that I used the SQL DB using SQLAlchemy and there I used models for organizing the database. Now I'm a bit confused how to organize ...
1
vote
1answer
68 views

Separate an email address into its username and domain name

This is my first ever Python program and I wanted to get everyone's opinions on it. The goal of the program is to separate an email address into its username and domain name. ...
1
vote
4answers
384 views

“Digit Queries” CSES Solution giving TLE

I really need a more accurate way to size inf_string. This code works but gets exponentially more inefficient the bigger max(queries) is, and therefore just can't hold up to the gargantuan numbers ...

1
2
3 4 5
93