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
3
votes
0answers
156 views

crossword using tkinter without classes and objects

For my python project, I wanted to make a crossword game GUI with sql connectivity to display high scores so I tried to learn tkinter the only difficulty was that I cannot use classes or objects as ...
3
votes
0answers
279 views

Python AsyncIO pipeline

I wrote a small snippet to implement asyncio Pipeline - object that connects together Layers, and lets them create and pass ...
3
votes
0answers
54 views

OOP parsing for DB dump XML Python

I am parsing large XML (DB dump). So, the content looks like many different objects with their properties and dependencies (foreign keys). My way to do it - using lxml.etree (iterparse): ...
3
votes
0answers
223 views

Calculating the total sum of inversion count for all subarrays

My approach was to visit all inversion count pair and count how many subarrays these pair contribute. Visiting every pair requires \$\mathcal{O}(n^2)\$ time, but I want an optimized version of this, ...
3
votes
0answers
70 views

SageMakerTrainingOperator in Airflow

I have made an operator (surrounded by others operators) for training a model in sagemaker in airflow and I have doubts how would it be more readable or more pythonic. First I did this: ...
3
votes
0answers
498 views

JSON to CSV in python using json.loads and json_normalize

I am trying to convert a JSON file to CSV format using Python. I am using the JSON.loads() method and then using json_normalize()...
3
votes
0answers
53 views

How can I make my Pygame Tic Tac Toe game better?

I have this code ready and it works just fine. But what are the ways by which I can improve this code? I have no CS background and this is my first coding project. I could not paste my entire code so ...
3
votes
0answers
774 views

Converts audio files to fixed size chunks and the chunks to spectrogram images

This code takes in input as audio files (.wav or .WAV) and divides them into fixed-size (chunkSize in seconds) samples. Then these chunks are converted to spectrogram images after applying PCEN (Per-...
3
votes
0answers
956 views

Python program to solve matrix-chain multiplication

An assignment at school required me to write a Python program for this task: In the matrix-chain multiplication problem, we are given a sequence of matrices ...
3
votes
0answers
54 views

Lowest cost path through elements in a matrix

I've developed a program in Python that calculates the lowest possible costing path between two points in a matrix, including the values contained in the start and finish cells. The code is below. ...
3
votes
0answers
100 views

Simplified Smart Rockets using Genetic Algorithm

This is a very bare bones program where a population of blocks learn to reach a target on a 2d screen (My attempt at making a smart rockets program) I've only used python for 2 weeks so i'm positive ...
3
votes
0answers
824 views

Extract the IP address from the output of ipconfig when connected to multiple wireless networks

I am trying to extract the ip address of my machine when connected to multiple wireless networks. The motivation here is then I can make a socket connection on that ip when I have two networks that ...
3
votes
0answers
41 views

Feedback on Object-Oriented ETL Class Structure for Computing Profit Summary Data

I am using Python 3 and pandas 0.24.2 to do some data processing and ETL flows. I have followed this pattern a couple of times and it is really bothering me but I am not sure which direction to go to ...
3
votes
0answers
32 views

spark takes long time for checking an array of items present in another array

I am new to spark. I have two dataframes df1 and df2. df1 has three rows. df2 has more than few million rows. I want to check whether all items in df2 are in transaction of df1, if so sum up the costs....
3
votes
0answers
173 views

Python 3 tkinter calculator

After a bit of a break away from any coding, I decided to return with something simple. As I haven't done much of GUI programming with python, and I would like to do more, I decided to make a simple ...
3
votes
0answers
524 views

Finding the submatrix with the maximum sum

Given an arbitrary \$N \times N\$ matrix, find the maximum sum submatrix. This particular approach uses the Kadane's algorithm. What could be improved both in terms of algorithm and code style? ...
3
votes
0answers
75 views

Find overlaps in ranges pairwise

I've wrote a function which take in a list of ranges (the ranges being tuples) and then returns a list of dictionaries which are a summary of how these ranges overlap with each other There's not a ...
3
votes
0answers
66 views

Metaclass to run a __first__ method for the first instantiation of a class

I had an idea for a __first__ special method for a class. It would be run after __new__ and before ...
3
votes
0answers
412 views

Export EXIF data from thousands of images to CSV

I have written a script that retrieves specific fields of Exif data from thousands of images in a directory (including subdirectories) and saves the info to a csv file: ...
3
votes
0answers
723 views

Given an input string and a pattern, implement wildcard pattern matching

I have been trying to solve "Wildcard Matching" on leetcode. I know there are more "manual" ways to solve this without using the RE library. But I would like to know if passing the time limit is ...
3
votes
0answers
416 views

Looking for words from a list of words in a sentence

Problem Given a Dictionary with user_id and a list of alert_words (words and phrases too look for in an sentence) and a ...
3
votes
0answers
326 views

First project “Game Tetris”, Python 3.4

I just study Python, and have finished my first personal challenge game Tetris. It has multi-game, bindable keys, customizable game field. It would be great to have review/feedback on it. https://...
3
votes
0answers
107 views

Loading into a target table

Today I tried Bonobo + SQLAlchemy (for the first time), so it's bound to be full of bad practices. However, this is working code. I'm hoping for some feedback to for doing it correctly. I started out ...
3
votes
0answers
435 views

unpack a nested dataclass and named tuple

I want to create a function that unpacks nested dataclasses and namedtuples (or a combination of both) my attempt I found this ...
3
votes
0answers
522 views

Using Python threads to download images

I am using Python threads to download images. I have a JSON file that contains URLs to the images in the following structure: ...
3
votes
0answers
24 views

Context manager to temporarily drop indexes and constraints on a table

I'm importing millions of rows into a PostgreSQL database using a foreign data wrapper. To speed this up I've written this context manager to DROP all the indexes ...
3
votes
0answers
666 views

Random name generator from JSON file

Tired of thinking up random names when following tutorials involving people? So was I. The code below is the first project I've written in Python. Put simply, it grabs a list of forenames and last-...
3
votes
0answers
231 views

Image Manipulation with PIL/Pillow - Picture effect/filter

I was curious about image manipulation and I was wondering how it was working, so I made some little functions wich are modifying the pictures passed in parameter. The graphics results are not too bad,...
3
votes
0answers
170 views

Amateur Python Sudoku Solver

I'm self-taught in Python and would have a lot of room for improvement. I made this basic Sudoku Solver mainly in order to practice the use of Class creation. I would greatly appreciate any feedback ...
3
votes
0answers
885 views

AVL Tree with delete method in Python 3

Just a general code review. I'm looking for my first developer job so anything constructive is awesome. Please, and thank you very much. I've written this implementation as an exercise and to add to ...
3
votes
0answers
80 views

Simple General Purpose Parser Implementation

This is an implementation of a general Purpose Parser/Matcher that can operate on any input stream of objects and will return all possible combinations. In this case I do not value performance that ...
3
votes
0answers
659 views

Memory release after joblib.Parallel [python]

Stuck with the issue with memory consumption - after running joblib's Parallel, deleting results and gc.collect() -ing I still have increased memory (checking by htop for process line). Found no way ...
3
votes
0answers
535 views

OOP Othello in Python with tkinter UI and basic AI

I wrote an Othello version with limited UI to try to learn python(3.7) and OOP. The game has 8 classes. Start creates a controller object which is responsible for the logical flow of the game. ...
3
votes
0answers
83 views

Binary Search Tree in Python 3

I just implemented binary search tree as described in Cormen's algorithm book. I'm not interested in correctness or performance of the implementation. I'm looking for reviews, comments on code style ...
3
votes
0answers
372 views

Simple Bank API script

I would really appreciate some feedback on this code. It 100% works (as far as I have tested it). Really just looking to improve where I can. This script is currently hosted on my local PC and is ...
3
votes
0answers
403 views

Making 10000 HTTP requests as fast as possible

I need a program that needs to gather data from large list of API end points. Below is a mock-up program that attempts to make 10000 requests as fast as possible. Any suggestions on how to improve on ...
3
votes
0answers
353 views

Tic Tac Toe engine in Python for Deep Learning

I'm implementing a Tic Tac Toe engine that will work with deep learning. I'm using a 3x3 numpy array of floats to represent the board. +1.0 represents an X, ...
3
votes
0answers
183 views

Merging bin-data via a bin count threshold

When performing a chi-squared test, one takes the square of the differences of the expected counts per bin and observed counts per bin, and divides these per-bin differences by the expected counts per ...
3
votes
0answers
104 views

Custom Day of the Week Manipulation

The function serves two purposes as follows: When dealing with the day of the week, Python will always assign 0 to Sunday and 6 to Saturday and I want to change that. The first part of the code is ...
3
votes
0answers
76 views

Numpy versus Theano GPU parallelization

I am learning Theano to accelerate my image processing functions. As a start, I am trying to reimplement the function to turn images from colors to black and white (with the same number of channels): ...
3
votes
0answers
1k views

tkinter calculator college project

I had this project where we had to build a calculator from scratch in Python. GUI was completely optional though I did include it. I'm currently awaiting grading on the project. (I have found that ...
3
votes
0answers
91 views

Investment tracker allowing users to store investment information and later access it

This investment tracker allows users to store investment information and later call upon it. This is a simple solution to making investing easier to maintain. This application has a simple login ...
3
votes
0answers
42 views

Deriving incremental feature representations for bit flips

Given a boolean 3D matrix and a set of actions specifying bit flips at certain positions, a set of resulting matrices can be obtained, one matrix for each action, as if executing each bit flip ...
3
votes
0answers
107 views

Program for memorizing irregular verbs (for Russian speakers)

I do not have any serious programming experience. The program is designed to memorize common irregular English verbs (for those who speak Russian like I do). The code is working. The necessary words ...
3
votes
0answers
80 views

Parsing XML to get report job id and save final XML to file from an API

The objective of this code is to contact a server with a reporting API and run the specified report from the user generated configuration file, once the report has been requested to server responds ...
3
votes
0answers
493 views

Compute distance matrix using DTW acceptable for scipy.cluster.hierarchy

I am new to both data science and python. I have a dataset of the time-dependent samples, which I want to run agglomerative hierarchical clustering on them. I have found that Dynamic Time Warping (DTW)...
3
votes
0answers
205 views

Message classification with Levenshtein Distance

I have a Python script that classifies messages. Each message carries a score, which is tallied up later in the script. It looks for messages that look alike, and puts them into a category. ...
3
votes
0answers
193 views

Database check in a loop

I have a python script that loads a database table and checks an API for the entries found. I do it like this: ...
3
votes
0answers
720 views

Python, matplotlib, 3d plot, how to make this code effective, light, fast?

I have already make a 3D mesh. See below: And the code below: ...
3
votes
0answers
302 views

ECDH implementation in python (part 3)

After the first and second part, the primary feedback I got was to rename a lot of my variables as I used the same name for different local variables which is really confusing. I tried to hotfix that, ...

1 2 3
4
5
11