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
1 answer
49 views

Getting and setting dict items via paths

I wanted to have something more convenient to work with nested dictionaries that come from yaml files so I wrote this ...
  • 44.1k
0 votes
0 answers
20 views

Generate INSERTs from function parameters with jinja2

I'm writing unit-tests with pytest for sqlite database and reporting functions and I need to arrange them by inserting minimal ...
  • 44.1k
1 vote
0 answers
15 views

Protecting functions from empty DataFrames

Pandas likes to throw cryptic errors when you feed its functions with empty DataFrames saying nothing that would help you to identify the root cause. In order to ...
  • 44.1k
1 vote
1 answer
17 views

Mapping pandas' Series to dataclasses

I've got something really simple this time where I'm mapping pandas' Series to dataclasses with a oneliner helper function (as ...
  • 44.1k
1 vote
1 answer
43 views

Rewritten Python script to split Insyde H2O firmware files

I’ve recently tried to update my Lenovo laptop’s firmware without installing Windows. I haven’t done it yet, but during their research someone on Matrix linked me to this page (original source, ...
0 votes
1 answer
24 views

Function to return a file name from lists/dictionary constants

I'm reworking a set of two functions that return a text file name, constructed from a string argument and string variables from a module called inventory. It seems ...
  • 229
-1 votes
1 answer
47 views

Graph function in console

I created a program for drawing graphs of functions and want to hear ideas on "how to improve this program", because I'm only starting to write programs in Python. Would be very good to hear ...
0 votes
0 answers
5 views

custom IoU loss for object detection training in Tensorflow2

I am training a single-class object detection model in Tensorflow/Keras. The input image can contain either 0 or 1 instances of the object of interest (no multiple bounding boxes). My model outputs ...
  • 111
2 votes
0 answers
24 views

Cancelling function execution with a ContinuationError

Although throwing excptions for control flow is a controversial topic there are some quite popular examples of using this anti-pattern like C#'s async routines throwing the ...
  • 44.1k
2 votes
1 answer
24 views

Convert sorted list to BST

I am working on a Daily Coding Challenge to convert a sorted singly-linked list into a binary search tree. We are given the head of the list; the definitions of ...
1 vote
0 answers
30 views

Search Stack Overflow and GitHub for code in a specified language

This code is designed to scrape Stack Overflow and GitHub, pulling information based on a user-specified programming language and processing the data into a format for AI learning. It uses a number of ...
0 votes
1 answer
62 views

Optimize system of equation function organizer with memory bottleneck in python

The Code So i have the following function that just gathers a system of equations so it can be input into the standard solvers of scipy ...
  • 113
3 votes
1 answer
57 views

A simple web scraper for nature.com news articles

I have created a simple web scraper that fetches news article previews from nature.com and saves each article to a file containing the article preview text. I am learning independently, so I would ...
3 votes
4 answers
530 views

Built a function to search a dictionary using key or value

I'm building an error handler which handles different kinds of errors arranged hierarchically. As part of that, I need a way to figure out what errors to send a recipient based on what their ...
0 votes
0 answers
46 views

Python script that parses GOG .hashdb files

I have some .hashdb files with names like goggame\-\d{10}\.hashdb in the installation folders in some of the games I have, and I want to extract information from ...
0 votes
2 answers
80 views

Find the shortest distance between two letters

I've been tasked with finding the distance between two letters in the alphabet. Below is my solution. My main concerns are if there is any shorter way to do this, and if there are any edge cases I'm ...
  • 9,719
0 votes
0 answers
45 views

Choose and locate a word in PDF

This code searches helps to choose a word and locate the word in a PDF, by highlighting it, and drawing a box around it. I found problem with the border of the rectangle, as it's thickness cannot be ...
2 votes
0 answers
54 views

Snake game with constant time complexity algorithm

https://github.com/speedrun-program/constant_time_snake_game Memory efficient snake game with O(1) algorithm for snake movement and bug placement. Three grids are used: a grid representing the game ...
3 votes
1 answer
92 views

Calculate overlap of two datetime objects

I would like to find out how much time lays in between 22.00 and 6.00 o’clock for a given event per day. So if the event start at 21.00 and ends at 23.59 the result would be 1.59. For a start at 22.00 ...
  • 31
2 votes
1 answer
31 views

Python Module for representation, calculus and rich comparisons between temperature scale instances

ToTemp is a temperature conversion package with Celsius, Delisle, Fahrenheit, Kelvin, Rankine, Réaumur, Newton and Rømer scales. With a documentation and already in PyPI. The source code for the main ...
  • 139
0 votes
0 answers
17 views

Flask App - create the admin account (Suggestios or Improvements)

I know this may be a silly question..., but I'm trying to create a function in python that allows me to register an account for the admin user. If the administrator does not specify any data, be it ...
1 vote
0 answers
44 views

Object detection YOLO v1 loss function implementation with Python 3 and TensorFlow 2.x

About the code Object detection YOLO v1 loss function implementation with Python + TensorFlow 2.x. It based on the Pytorch implementations below and re-implemented with TensorFlow based on my ...
  • 111
2 votes
1 answer
71 views

Update an Excel master workbook with values from new workbook

I have a master .xlsx file on which other spreadsheets depend. Each week, I export a new .xlsx file (from MRP) that may or may not be the same as the master. The columns are always identical. Rows may ...
2 votes
1 answer
57 views

"Tic-Tac-Toe" implemented in Python

With the following code I implemented the mini-game "Tic-Tac-Toe" in Python. However, I am still a beginner in programming and I wanted to ask if someone could give me some tips on how to ...
6 votes
2 answers
882 views

Python script to get and save data from a web API

I'm working as a system administrator (sort of), but learning Python on the side. Life gave me a chance to apply that knowledge, since our organization is being provided cloud email service, and it ...
0 votes
0 answers
47 views

Walk a folder of files and extract creation date, countries mentioned and a summary based on their text for each

I made a script that scans a folder of 723 documents (pdf, pptx, docx) to extract the 'Name', 'Type', 'NbPages', 'Creation Date', 'Period Date', 'Countries', 'Summary', 'Indicateurs', 'Path'. I think ...
3 votes
2 answers
93 views

Custom-made spellchecker with Wiktionary

I have been coding on Python for two weeks. All I want the code to do is this: Check if each word in sentence has an English category Wiktionary article Ignore all words inside quotations and proper-...
  • 133
2 votes
3 answers
92 views

Wordlist formatter code

I am making a "wordlist cleaner" module that loads a words.txt file, and returns a list of cleaned/sorted words. Full code: ...
  • 35
0 votes
1 answer
144 views

Type hints and expected types

I'm unsure if this question belongs on Code Review or Stack Overflow. Another developer told me that I should consider adding type hints to my open source project WordHoard. I have never used type ...
1 vote
1 answer
72 views

Excluding attributes entirely vs. setting them to None

I am making a program that parses profiles from a website. Some profiles are "public" and others are "private" with limited information. Public profiles contain a lot more data and ...
  • 35
4 votes
0 answers
151 views

constraint solving graduation using HTML Parsing, pandas, and z3

not sure if this project fits on code review, but my code is getting extremely messy, and would love some tips to clean it up! Overview The project is designed to take in an HTML file (a degree audit),...
  • 169
1 vote
0 answers
27 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 ...
  • 53
3 votes
1 answer
77 views

Tap-Type-Game in Python (fast-typer)

Hello everyone Last week I've started creating a little project for fun - TapType Game, I know there is a lot of things to make better, but what about my solution, can you give me some general tips, ...
1 vote
1 answer
59 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 ...
3 votes
1 answer
104 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 ...
  • 111
4 votes
2 answers
155 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 ...
3 votes
2 answers
106 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,...
8 votes
3 answers
122 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,...
1 vote
0 answers
26 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 ...
  • 23
0 votes
0 answers
58 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
19 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
51 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
1 answer
373 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
2 answers
248 views

A selection sort implemented in Python

I'm not proficient at Python. My question is twofold: whether this selection sort algorithm implementation for number lists could be considered clean code (in the sense of being modular and ...
  • 257
1 vote
1 answer
43 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 ...
4 votes
1 answer
260 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
89 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 ...
  • 43
9 votes
2 answers
130 views

iChemistry - Learn chemistry with python

I decided to build a quiz type of game for improving chemistry linguistics using python. Currently there is not much variety in terms of questions, but before expanding the question base, I would like ...
8 votes
2 answers
249 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 ...
0 votes
0 answers
30 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 ...
  • 77

1
2 3 4 5
105