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
24 views

Mangle words to bytearray of lo/hibytes

I would like to refactor the following code snippet adapted from a project I'm involved. It is part of a code to control power outlets via network. The code snippet was written by myself based on the ...
3 votes
2 answers
122 views

Saving Scraped Data to a File

When scraping and saving data into a file, Which method is more efficient when saving scraped data to a file? open the file first, scrape, and save the data all ...
4 votes
1 answer
107 views

MultiLingual Online Translator

So i made a program, which allows you to translate from one language to another using the command prompt. I would like advice about the design, optimizations, and the tips and tricks to avoid ...
2 votes
1 answer
69 views

Game of life(random generation, pygame)

I recently created game about life in python. First version of code was console, but recently I rewrote this game in pygame. I decied upgrade game and was added age of cells. But now I can see that my ...
6 votes
3 answers
2k views

Simulated card trick with splitting and reordering

I need a bit of help with a practice Computer Science coursework. I have written a code for a magic trick (more information below) using Python 3.x, and for one particular section, I need to suggest ...
6 votes
2 answers
2k views

Game of life(random generation)

I wrote a simple game using python, but I wonder: how I can improve it? Any opinions will be useful. I thought about optimization, since the program consumes 20% processor resources, but don't know ...
0 votes
3 answers
777 views

To automate scheduling at the Italian Consulate

I'm a beginner developer in Python and I need some tips to improve my code, in performance (speed) and hardware usage. Is it possible to improve? And I have a question: is it possible to keep the ...
3 votes
1 answer
53 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 ...
1 vote
3 answers
183 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 ...
1 vote
1 answer
66 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 ...
6 votes
1 answer
867 views

Block storage rewrites

Summary In a block storage system, new data is written in blocks. We are going to represent the flash memory as one sequential array. We have a list of block writes coming in the form of arrays of ...
1 vote
1 answer
89 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 ...
0 votes
0 answers
44 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 ...
3 votes
1 answer
101 views

API design of library for argument inspection & filtering

I wrote the following Python library for getting a callable's argument names, testing whether a callable takes an argument with a given name, and filtering a dict ...
1 vote
2 answers
3k views

Account signup/login program in Python

This is my first program that I wrote on my own. Is there something I can improve upon? There are a few things that still need to be added, such as: Confirm password while registering Adding a way to ...
13 votes
1 answer
674 views

Bratwurst.py - A helper program for a cashier

I am a student in Germany, more specifically in Bavaria, and here we use to have a so-called "Kirwa", an event for celebrating the establishment of the local church - technically that's the ...
1 vote
1 answer
53 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, ...
9 votes
2 answers
170 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 ...
3 votes
1 answer
654 views

Python function to output a string that is justified to the right

I just solved this exercise from Think Python, 2nd edition: Python provides a built-in function called len that returns the length of a string, so the value of len('allen') is 5. Write a function ...
0 votes
1 answer
32 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 ...
7 votes
1 answer
213 views

Binary search algorithm (Python 3.9)

New to using this platform and would like to familiarise myself with it so would just like to ask if I am exhibiting good practice with my programming. Started the online CS50 course today and thought ...
-1 votes
1 answer
62 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 ...
1 vote
0 answers
183 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 ...
0 votes
0 answers
14 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 ...
3 votes
1 answer
64 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 ...
4 votes
1 answer
110 views

Theory-based quiz grader using similarity

I wrote a fairly simple program that grades theory-based quizzes. It is fairly straightforward. I would love to get insights and ideas on how it might be improved. ...
2 votes
1 answer
27 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 ...
4 votes
4 answers
544 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 ...
2 votes
3 answers
96 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: ...
0 votes
1 answer
65 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 ...
1 vote
0 answers
45 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
2 answers
92 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 ...
0 votes
0 answers
57 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 ...
2 votes
1 answer
34 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 ...
0 votes
0 answers
49 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
71 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
155 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 ...
0 votes
0 answers
25 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 ...
2 votes
1 answer
77 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
65 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 ...
3 votes
2 answers
99 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-...
6 votes
2 answers
904 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
59 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 ...
0 votes
0 answers
185 views

Python one-line binary search

...
0 votes
1 answer
186 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 ...
4 votes
0 answers
156 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),...
1 vote
1 answer
76 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 ...
0 votes
2 answers
157 views

How to speed up combinations code

...
6 votes
2 answers
255 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 ...
3 votes
1 answer
80 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, ...