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
1 vote
0 answers
28 views

Improving the readability, extensability, and optimization of a custom ETL Pipeline library (Pypeline.py)

I'm looking to improve the logic used in this ETL pipeline manager. The concept creates a structure: Pipeline(Pipe(Task, [Task, ...]), [Pipe(...), ...]) ...where a ...
3 votes
1 answer
112 views

Solve an option pricing PDE in Python - Part 1 [closed]

The Github repository NM-Heston solves call option prices under the Heston 2-factor model using ADI splitting schemes. I am adapting the code to price options under the 3-factor Heston-Hull-White ...
4 votes
1 answer
930 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, ...
3 votes
2 answers
112 views

Sort a dict by keys, assuming keys are orderable

I found a suspicious code snipped in an existing project in which I am involved as a developer. The code sorts a dict by its keys, so that if iterated over the dict,...
1 vote
1 answer
95 views

Python boto3 code to get the matrics from aws cloudwatch

I am working on a boto3 library and getting some metrics from aws cloud service cloud watch and that works perfectly fine, however, I am placing this question just ...
5 votes
1 answer
183 views

Algorithm Optimization -- Automatic Dimensionality of PCA

I have implemented (rather, edited the implementation of) a technique to automatically detect the optimal number of dimensions for PCA, based off of this paper. This was inspired by ...
8 votes
1 answer
2k views

Joystick to mouse/keyboard mapping program

I've been working on a project to map a joystick (in my case Logitech Extreme 3D) to mouse and keyboard so I can use it for web games that don't support gamesticks. My design goals are: Flexibility - ...
3 votes
1 answer
2k views

Update Google Sheet with Python

Below is a code to update a google sheet using the database values. The script is working fine but it is rather slow because of the sleep function which I have to put because of the "Quota exceeding ...
4 votes
2 answers
173 views

Simple implementation of Rock, Paper, Scissors game in Python

This is my first attempt at writing code from scratch. I'm visually impaired and would like to know if the code is well structured, commented and readable for a collaborator who might read it in the ...
8 votes
3 answers
126 views

Compressed output of set in Python

In order to provide a better output of sets with many consecutive elements (a similar class could be written for a list or tuple,...
5 votes
0 answers
166 views

@lazylist - Converts a Python Generator to a List without evaluating every element

Inspired by a blog I read, I made a LazyList class that can wrap an iterable (list, generator etc.) and turn it into a ...
6 votes
1 answer
480 views

Go Chess (weiqi) in Python using Tkinter

The Game Go or weiqi is an amazingly simple yet complex board game. This game is typically played on a 19x19 grid, and pieces are played on the intersections of lines. Pieces are removed when they are ...
1 vote
0 answers
42 views

Save Game Editor in Python/PySide

I'm developing a Xenoblade Chronicles 3 save data editor in Python with PySide6. My experience in Python has, over the years, been terminal scripts or web applications, so GUI scripting is completely ...
0 votes
1 answer
77 views

Better way to iteratively extend a list in Python [closed]

Is there a way to collapse multiple_get into as few lines as possible? ...
5 votes
1 answer
7k views

Iterate over chunks of date range in Python

...
0 votes
1 answer
59 views

Automate the Boring Stuff with Python 2nd Edition - Chapter 8 - Sandwich Maker Project [closed]

I am learning Python through Automate the Boring Stuff. And I was trying to do the practice project Sandwich Maker in Chapter 8, although I somehow already solved the problem but I encountered some ...
0 votes
0 answers
67 views

How to efficiently store and compute forecasting curves?

Let PD be a Plane/Date couple. For each PD, I would like to predict the forecasted booking curve, i.e. the cumuled amount of bookings registered each day between X days before departure and departure. ...
0 votes
0 answers
20 views

Automated back up of feature layers in ArcGIS Online - How could this code be condensed?

I currently work as a GIS Coordinator for a small scale utility that uses AGOL. That being said, many of our feature layers are hosted in AGOL and are regularly edited or modified in the AGOL ...
0 votes
1 answer
987 views

A program that calculates hourly wage / overtime

Question Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked ...
6 votes
1 answer
1k views

Python 3 script to make photo collages

I have written a Python script that takes a list of filenames of pictures and generates a photo collage of them. This is my most complex project yet, and I have written it completely by myself (like I ...
6 votes
1 answer
825 views

Asyncio HTTP Request Queue

I wrote a simple sitemap.xml checker using asyncio and aiohttp. I followed the documentation demonstrating the producer/consumer pattern. However, I noticed that as the URLs scale larger, it seems to ...
6 votes
1 answer
281 views

How to make my groupby and transpose operations efficient?

I have a DataFrame of size 3,745,802 rows and 30 columns. I would like to perform certain groupby and ...
6 votes
1 answer
120 views

Code optimisation: Converting dataframe to numpy's ndarray

I am working with a dataframe of over 21M rows. ...
7 votes
1 answer
1k views

Parsing different categories using Scrapy from a webpage

I've written a script in Python Scrapy to parse different "model", "country" and "year" of various bikes from a webpage. There are several subcategories to track to reach ...
1 vote
1 answer
45 views

Is this a correct way of doing ECS?

I'm trying to use ECS with Pygame and was wondering if I'm doing this right before I go any deeper than this. I've tried learning more about ECS but it's mostly in another language, which I could ...
6 votes
1 answer
1k views

Execute coroutines in pool

I want to run all the coroutines from the list in a pool of constant size and would like to ask if this is the right way how to achieve it. Is there any built in solution for this problem? I have not ...
9 votes
1 answer
97 views

A program that calculates how dense each character appears when printed

I wanted to know how "dark" each character is when printed. I thought that this may be useful when doing ASCII-art to help with shading. I decided to write a program to objectively measure ...
6 votes
2 answers
193 views

Crawling a court website and downloading records

I am new to Python and I am using Python 3.8 and Selenium. This is a follow up of my previous question. Since I received several useful suggestions I have re-written the following code. The code works ...
4 votes
1 answer
264 views

Slot Machine Project

I am familiar with Python but recently I have been trying to solidify my skills as a Python developer. I decided to do a project that would help me build some skills using the fundamentals of the ...
4 votes
2 answers
106 views

Sort todo.txt items by due date in Python 3

I am using the following format for my task management: https://github.com/todotxt/todo.txt Do some stuff +uni due:2022-12-31 Write some paper +uni due:2023-01-10 ...
8 votes
2 answers
577 views

Text based chess game in Python

I have reached a significant milestone since the start of my chess game project. I have implemented all basic functionality. There is no castling, en passant and pawn promotion yet but I have ...
7 votes
1 answer
93 views

Web Crawler for notice of assessment retrieval

Context: I want to check if notice of assessment are valid. What I did: I wrote some code to extract textual information from PDF (with OCR on image contained in the PDF): ...
0 votes
0 answers
32 views

Synchronized insertion to InlfuxDb using Python

I am connecting to various topics of the exchange websocket to fetch the data into the callback function, where it will insert to the InfluxDb, however, I am afriad the way I do below has low ...
2 votes
1 answer
277 views

How to structure in handling websocket and inserting data to databse in Python

I connected to the websocket, and the data response in the callback function handle_message. I wish to insert all the data to influxdb using ...
0 votes
2 answers
277 views

Binary Search written in python with O(n) [closed]

def search(nums, target): for i in range(len(nums)): if nums[i] == target: return i if nums[i] == None: return -1 I think ...
1 vote
1 answer
116 views

Simple text-game navigation system

I am a total newbie when it comes to coding in general, let alone Python. After following a few tutorials, I decided to try making my own little navigation system for simple maps, sort of drawing from ...
0 votes
1 answer
58 views

Checking several strings against a n-depth list of lists and returning one if its values

The data structure I am working with is a list of lists that is created by parsing a file. The depth of the list can vary. The list can have n Strings before its child-value begins. My current example ...
3 votes
3 answers
195 views

Most effective search algorithm for guessing list of strings via function returning bool if substring is in list using Python

I trying to figure out the most effective way to accomplish this task: A function, check(), contains a list of strings. Calling the function with a string as ...
1 vote
0 answers
25 views

Optimizing search algorithm for guessing list of strings via function returning bool if substring is in list [duplicate]

I trying to figure out the most effective way to accomplish this task: A function, check(), contains a list of strings. Calling the function with a string as ...
user avatar
0 votes
2 answers
137 views

A Python program that will determine an employee's commission based on his or her sales

I need help with this program: Create a program that will accept the user's name and ID number. The program will then ask for the department code, 1 is for the Toy Section, 2 for Ladies' Wear, 3 for ...
7 votes
1 answer
13k views

Flight booking system

I'm attempting to improve my OOP design skills through solving sample problems. Below is an implementation of a flight booking system where the passenger can only request a seat class, but no number. ...
4 votes
2 answers
315 views

Project Euler # 53 Combinatoric selections in Python

There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In combinatorics, we use the notation, 5C3=10. In general, nCr = n! / r! (n−r)!, ...
1 vote
0 answers
103 views

write a wrapper for cosmos db calls to use the results as objects in python (technically an ORM)

As part of a larger program, I'm trying to find the cleanest way to architecture my program to query a cosmos db and use its return values (dict objects) as easy to manipulate and maintain objects in ...
0 votes
1 answer
103 views

Translating excel spreadsheets

Context: This is a program that translates spreadsheets to English from Dutch using another custom library (transl). Question: Would like to hear criticism or advice on how to make the code better - ...
0 votes
0 answers
81 views

How to optimise this cosine similarity loop and function in Python?

I need to find cosine similarities between two lists of different sizes. I have this code but it is running for a long time. The first list has 40 000 words and the second list has 400 words. Is it ...
1 vote
1 answer
73 views

Further optimizing the ISING model

I've implemented the 2D ISING model in Python, using NumPy and Numba's JIT: ...
3 votes
3 answers
257 views

Python program to find all possible ways an integer num can be expressed as sum of integers between 1 and lim

This is a Python program that finds all possible ways a positive integer num can be expressed a sum of a number of integers between 1 and ...
2 votes
0 answers
54 views

Get priority of trucks (Advent of Code 2022: Day 3)

...
0 votes
1 answer
214 views

Calculate score of rock-paper-scissors (Advent of Code 2022: Day 2)

Advent of code, Day 2. Here is my code. Less verbose version of the question follows. ...
2 votes
1 answer
66 views

Optimize python computation of transition matrix

I have an array of integers labels, for instance array([0, 1, 1, 2, 2, 2, 3, 3, 1, 4, 4, 1, 1, 0, 0, -1, -1]). The array can be ...