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.

548 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
673 views

Implement OO interfaces in Python

Edit: Whoops! I just remembered there's already an long-lived package for this, zope.interface. I'd like a review all the same. This is a proof-of-concept ...
4
votes
0answers
346 views

Skiena's DFS on unweighted graphs, in Python 3, with adjacency-list implementation

In the Algorithm Design Manual (2nd ed) pp 172 - 173, Skiena writes: As algorithm design paradigms go, a depth-first search isn't particularly intimidating. It is surprisingly subtle, however ...
4
votes
0answers
215 views

Simple Stateful LSTM example with arbitrary sequence length

I'm trying to make a simple example showing how to create a RNN with Keras that accepts as input a sequence of arbitrary length. In my example, the LSTM is trying to classify whether a sequence has ...
4
votes
0answers
1k views

Sanitize and standardize street addresses using Google Maps lookups

Take in incomplete user input street addresses, clean it, segregate based on word count and run it into Google maps places api and output completed & standardised addresses based on Json object ...
4
votes
0answers
1k views

Open a file selection window to top-most position from jupyter notebook

Background I came up with this solution to a question that I posted on stackoverflow. It uses Tkinter to create a file select dialog window and raise it to the topmost position from jupyter notebook. ...
4
votes
0answers
601 views

PyQt GUI to add and remove dots

Initially I got this code: ...
4
votes
0answers
122 views

Blender exporter for Unreal Engine 1 brushes

Unreal Engine 1 nowadays is slightly useless, but it still is (kinda) flexible and allows for modifications of extensive kinds, including many sorts of maps. However, one of it's editor, Unreal ...
4
votes
0answers
620 views

Tkinter RSS feed

I am creating a GUI program using Tkinter wherein I utilise the Feedparser module. My code executes in the following way: Get the stock ticker to insert into the URL from the user. Parse the URL and ...
4
votes
0answers
567 views

PySpark Dataframes program to process huge amounts of server data from a parquet file

I'm new to spark and dataframes and I'm looking for feedback on what bad or inefficient processes might be in my code so I can improve and learn. My program reads in a parquet file that contains ...
4
votes
0answers
541 views

Building Data abstraction and ADT for rectangle using “objects”

For the below given exercise: Exercise 7: Abstracting Rectangles Implement a representation for rectangles in a plane. (Hint: You may want to make use of your procedures from exercise 5). Then, in ...
4
votes
0answers
1k views

Python proxy class

I've coded my own proxy class in python. The aim is to have a different type() but otherwise behave as identical to the underlying object as possible. I'm wondering ...
4
votes
1answer
84 views

Highlighting partitions in distinct color

Given: G is an arbitrary graph partitions is a list of its edges divided into (in this case) 3 sets. Color generation: Its ...
3
votes
1answer
54 views

Merging pages together into an append log

Situation I'm scraping data from a paginated list on a website to be sent out as notifications. For the most part we'll only need to scape the first page and handle additions, deletions and duplicates....
3
votes
1answer
45 views

Simple Python Recursive Web Scraper

I tried to make a simple recursive web scraper using Python. My idea was to grab all the links, titles and tag names. Website: https://lifebridgecapital.com/podcast/ Course of Action: Grab all the ...
3
votes
0answers
44 views

Speed Up API Requests & Overall Python Code

I'm not asking for help solving a problem but rather asking for help for possible ways to improve the speed of my program. Essentially what this does is: Tracks market data by pulling the data from ...
3
votes
1answer
20 views

Python script that converts Windows Registry Scripts (.reg) into PowerShell scripts (.ps1)

Well this a re-implementation of a PowerShell script that I wrote which does exactly the same thing, and I have ported it into Python. After a quick Google search I found that there is only one other ...
3
votes
0answers
40 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 ...
3
votes
0answers
57 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 ...
3
votes
0answers
80 views

Python - Get Unique frames of video containing object

I am analyzing videos from the popular social media platform, TikTok, and extracting the songs into a Spotify playlist. Here is a gif of one of these videos: https://i.imgur.com/I0dVoac.mp4. Full ...
3
votes
1answer
44 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. ...
3
votes
1answer
129 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 ...
3
votes
0answers
247 views

Playing pong (atari game) using a DQN agent

I trained a DQN agent using tensorflow and OpenAI gym Atari environment called PongNoFrameskip-v4, but this code should be compatible with any ...
3
votes
1answer
64 views

Cyclic generator with access to current local state and executes callback after each cycle

I'm working on a Python class that is a cyclic generator, like itertools.cycle, but it offers access to its current state and executes a callback after the ...
3
votes
0answers
53 views

Graph: A backcountry explorer

Would you help me? I want to make this code efficient and simple. Original Link Frodo, a backcountry explorer, came to explore an underground cave with n rooms during his expedition. All rooms are ...
3
votes
0answers
42 views

Assembly REPL in Python using ctypes

I created a assembly REPL using some ctypes hacks to run the assembly code. Any suggestions on how I could improve it? I am unconcerned about some of the "obvious" security issues such as ...
3
votes
1answer
40 views

Approximation search source reconstruction localization algorithm

Goal To determine the coordinates of some signal source in a 3D space, given the coordinates of four observers and the time at which each saw the signal, as well as the velocity of the signal. ...
3
votes
1answer
67 views

Function for accessing and searching dictionaries using /slashed/paths (like xpath)

So I have some data being returned to me in the form of a deeply nested Dict and I need to parse multiple values from it which may or may not be there. I saw this library (https://github.com/...
3
votes
0answers
63 views

Asynchronously extract title from URLs using Python

The following code asynchronously extract title from URLs (saved in book-urls.txt). ...
3
votes
0answers
188 views

Suvat Calculator - Kinematics

Suvat stands for kinematics or (s)displacement (u)initial velocity (v)final velocity (a)acceleration (t)time This calculator can find the remaining 2 variables given 3 other variables! Enter x on the ...
3
votes
0answers
65 views

Implement kleptography in Python

I'm new here, therefore I hope to be clear in this question. Firstly, I want to underline that I'm not a programmer, and I attended only a beginner course in Python, but I like to solve problems ...
3
votes
0answers
107 views

Simple SYN Port Scan Using Scapy

I decided to try writing up a port scanner to develop my understanding of Scapy. Here's a timed example of its use. The first two arguments are the address and range of ports to scan: ...
3
votes
0answers
73 views

Providing a connection pool

I need some opinions about method naming and single responsibility principle. First of all, let's talk about method naming. The class below was created to provide a connection pool and whenever a pool ...
3
votes
0answers
123 views

Split money into every possible combination of coin denominations

Background and objective of the code Based on this Dev.to challenge, I wrote the Python code below (TIO link also available). The task was to return the least number of coins in a given denomination ...
3
votes
0answers
42 views

Splitting an image in batches of tiles

I have a large image and I am extracting and processing tiles in batches of a given size. A tile is normally a 256x256 region and batches are normally a power of 2. In the below example the number of ...
3
votes
0answers
63 views

Monte Carlo Simulation of a Markov Process

A 1D binary string has the following dynamics $$1100 \to 1010,\quad 1101\to 1011$$ each with rate \$p<1\$. That is if we see \$110\$ in the string, then we change to \$101\$ with probability \$p\$....
3
votes
0answers
117 views

Noughts and Crosses Terminal Game with AI

I created a game which can play tic-tac-toe with: 0 players (AI vs AI), 1 player (human vs AI) or 2 player (human vs human). Here is the AI function which wraps around my innermost function. This ...
3
votes
0answers
80 views

Model Program For Food Orders - Too many 'break' statements

I made a program which simulates taking an order for 3 meals and a dessert. It's like those packaged food companies you see on Instagram. It asks for a name, and then goes on to ask what they want for ...
3
votes
0answers
58 views

Nvidia Energy Consumption Watcher

The idea was to write a context manager that would calculate energy consumption for the given machine learning pipeline running on a GPU. It does it by polling the current power consumption using the ...
3
votes
0answers
243 views

Match lists and get value of one column based on values of other columns from dataframe optimization

I have an input dataframe like below, where 'ID' is unique identifier, 'Signals_in_Group' is a derived field containing list of all unique 'Signal' column values present in a 'Group'. And '...
3
votes
0answers
136 views

Improving Performance of Numba For-Loop and Matrix Multiplication for Time Integration Solver

I am writing some code that performs a simple time-history integration solver (Newmark method for structural dynamics) and I looking for some suggestions in how I can improve the performance of my ...
3
votes
0answers
292 views

Coffee machine in Python 3

I've been struggling with python OOP. I've gone through the basics but I'm struggling with implementing them. So I've decided to create something small everyday while in quarantine to get more ...
3
votes
0answers
123 views

Snake game with multiple snakes

Firstly, I wrote standard snake game, then I decided to increase difficulty and made game with various snake number. My main point was to try the curses module, the second - to create game with OOP ...
3
votes
0answers
81 views

A game implementation in Python

I have the following Connect 4 implementation. Is there a way to refactor it and maybe make it better. It's a fully working solution. However, I see that the correct result is not returned in certain ...
3
votes
0answers
23 views

Django migration script to add metadata

I made a simple django migration that adds two field to our Invoices model : first_payment and first_paying_month. ...
3
votes
0answers
400 views

a kinematics(suvat) equation solver for micropython

so i made a python program for my calculator's micro-python that lets you enter a value for any 3 of these variables ...
3
votes
0answers
210 views

Print numbers from video frames to console using pytesseract

This is my first ever Python program. It checks every frame of a video file with Tesseract then uses OCR to recognise numbers in that frame and prints it to the console. ...
3
votes
0answers
187 views

Clean and fast MiniMax for numpy implementation of Tic-Tac-Toe

Tic-tac-toe is small enough to be solved completely but since I have a slow computer and this is an interesting exercise, I want to build the fastest possible minimax tic-tac-toe implementation in ...
3
votes
1answer
148 views

Given an integer array A and a range, find a subarray within the range with a minimum sum

Problem HackerRank Range query: You are given an array A of n integers. You have to perform ...
3
votes
0answers
100 views

Compare historical data

I have the following function that is supposed to compare current and historical transactions for each id. The logic seems to work ok, but the performance is extremely low for the amount of data I'm ...
3
votes
0answers
59 views

First Attempt at Object-Oriented Programming: Tic-Tac-Toe

Began learning python about 3 months ago and this was my first OOP. I was hoping to get constructive feedback! My own thoughts after writing it were that there had to be a better way to: 1) generate ...

1 2
3
4 5
11